Closed
Description
I tried this code:
mod a {
mod b {
macro_rules! macro_b {
() => {
"Hello, world!"
};
}
pub(crate) use macro_b;
}
pub use self::b::*;
}
fn main() {
println!("{}", a::macro_b!());
}
I expected to see this happen: No warning generated
Instead, this happened: cargo check
generated such warning
warning: glob import doesn't reexport anything because no candidate is public enough
--> src/main.rs:10:13
|
10 | pub use self::b::*;
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Though the warning says that glob import doesn't reexport anything, commenting out this line leads to error:
error[E0433]: failed to resolve: could not find `macro_b` in `a`
--> src/main.rs:14:23
|
14 | println!("{}", a::macro_b!());
| ^^^^^^^ could not find `macro_b` in `a`
warning: unused macro definition: `macro_b`
--> src/main.rs:3:22
|
3 | macro_rules! macro_b {
| ^^^^^^^
|
= note: `#[warn(unused_macros)]` on by default
warning: unused import: `macro_b`
--> src/main.rs:8:24
|
8 | pub(crate) use macro_b;
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
For more information about this error, try `rustc --explain E0433`.
The warning will not be generated when any other pub functions are added into module b and exported. It happens when the module only exports macros.
Meta
rustc --version --verbose
:
rustc 1.74.0-nightly (65ea825f4 2023-09-18)
binary: rustc
commit-hash: 65ea825f4021eaf77f1b25139969712d65b435a4
commit-date: 2023-09-18
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0