-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.L-unused_importsLint: unused_importsLint: unused_importsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
mod macros {
#[macro_export]
macro_rules! some_macro {
() => {{println!("Hello, World")}};
}
}
pub use macros::*;
Current output
warning: unused import: `macros::*`
--> src/lib.rs:8:9
|
8 | pub use macros::*;
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: `tester` (lib) generated 1 warning (run `cargo fix --lib -p tester` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
Desired output
warning: unused import: `macros::*`
--> src/lib.rs:8:9
|
8 | pub use macros::*;
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
= note: this import only imports macros exported with `#[macro_export]`, therefore the `pub use` does nothing
warning: `tester` (lib) generated 1 warning (run `cargo fix --lib -p tester` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
Rationale and extra context
I ran into this myself, because I'm so used to pub use ...
functions/structs to nicely organise my libraries.
So I think this can also help others who don't realise that #[macro_export]
makes the pub use
unnecessary.
Other cases
No response
Rust Version
rustc 1.84.0-nightly (4f2f477 2024-10-23)
binary: rustc
commit-hash: 4f2f477
commit-date: 2024-10-23
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.L-unused_importsLint: unused_importsLint: unused_importsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.