Please consider the following structure:
.
├── Cargo.lock
├── Cargo.toml
└── src
├── main.rs
└── mod1
├── bar.rs
└── mod.rs
The content of files:
// mod1/bar.rs
pub fn pp() {
println!("Print from bar");
}
// mod1/mod.rs
mod bar;
pub use self::bar::*;
// main.rs
mod mod1;
fn main() {
mod1::pp();
}
# Cargo.toml
[package]
name = "test-2018"
version = "0.1.0"
edition = "2018"
Running cargo run
raises the following error:
error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130)
--> src/mod1/mod.rs:3:9
|
1 | mod bar;
| -------- not an extern crate passed with `--extern`
2 |
3 | pub use self::bar::*;
| ^^^
|
note: this import refers to the module defined here
--> src/mod1/mod.rs:1:1
|
1 | mod bar;
| ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: Could not compile `test-2018`.
To learn more, run the command again with --verbose.
I tried cargo fix
with no success and got the same error as cargo run
I forgot to add self
and now it is working fine.