#![no_std]
use soroban_sdk::{contract, contractimpl};
mod feat1;
mod feat2;
#[contract]
pub struct Contract;
#[contractimpl]
impl Contract {
pub fn base() -> u32 {
0
}
}
src/feat1.rs:
use soroban_sdk::contractimpl;
use crate::Contract;
use crate::ContractClient;
#[contractimpl]
impl Contract {
pub fn one() -> u32 {
1
}
}
src/feat2.rs:
use soroban_sdk::contractimpl;
use crate::Contract;
#[contractimpl]
impl Contract {
pub fn two() -> u32 {
2
}
}
What did you expect to see?
Compiled successfully, and test successfully.
What did you see instead?
$ soroban contract build
cargo rustc --manifest-path=Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
Compiling test_modular v21.5.1 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/modular)
error[E0412]: cannot find type `ContractClient` in this scope
--> tests/modular/src/feat1.rs:6:1
|
6 | #[contractimpl]
| ^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro `soroban_sdk::contractclient` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
1 + use crate::ContractClient;
|
error[E0412]: cannot find type `ContractClient` in this scope
--> tests/modular/src/feat2.rs:6:1
|
6 | #[contractimpl]
| ^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in the attribute macro `soroban_sdk::contractclient` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
1 + use crate::ContractClient;
|
For more information about this error, try `rustc --explain E0412`.
error: could not compile `test_modular` (lib) due to 2 previous errors
After adding in these lines to feat1.rs and feat2.rs:
use crate::ContractClient;
Build worked fine, but cargo test failed:
❯ cargo test
Compiling test_modular v21.5.1 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/modular)
error[E0433]: failed to resolve: use of undeclared crate or module `__Contract_fn_set_registry`
--> tests/modular/src/feat1.rs:6:1
|
6 | #[contractimpl]
| ^^^^^^^^^^^^^^^ use of undeclared crate or module `__Contract_fn_set_registry`
|
= note: this error originates in the attribute macro `contractimpl` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
|
1 + use crate::__Contract_fn_set_registry;
|
error[E0433]: failed to resolve: use of undeclared crate or module `__Contract_fn_set_registry`
--> tests/modular/src/feat2.rs:6:1
|
6 | #[contractimpl]
| ^^^^^^^^^^^^^^^ use of undeclared crate or module `__Contract_fn_set_registry`
|
= note: this error originates in the attribute macro `contractimpl` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
|
1 + use crate::__Contract_fn_set_registry;
|
For more information about this error, try `rustc --explain E0433`.
error: could not compile `test_modular` (lib test) due to 2 previous errors
What version are you using?
v21.5.1
What did you do?
Cargo.toml
:src/lib.rs
:src/feat1.rs
:src/feat2.rs
:What did you expect to see?
Compiled successfully, and test successfully.
What did you see instead?
After adding in these lines to
feat1.rs
andfeat2.rs
:Build worked fine, but
cargo test
failed: