Cargo.toml
has two [[bin]]
sections:
[[bin]]
name = "main1"
path = "src/main1.rs"
[[bin]]
name = "main2"
path = "src/main2.rs"
Both main1.rs
and main2.rs
have the same main function that calls
some::submodule::hello()
:
fn main() {
some::submodule::hello();
}
Why does main2.rs
fail to compile even though main1.rs
compiles fine?
$ cargo build
Compiling rust_second_bin v0.1.0 (/path/to/rust_second_bin)
error[E0433]: failed to resolve: use of undeclared crate or module `some`
--> src/main2.rs:2:5
|
2 | some::submodule::hello();
| ^^^^ use of undeclared crate or module `some`
See the source code here.
$ cargo --version
cargo 1.76.0 (c84b36747 2024-01-18)
$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)
$ uname -a
Darwin mymac.local 22.6.0 Darwin Kernel Version 22.6.0: Mon Apr 22 20:51:33 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_ARM64_T8112 arm64