`unused_imports` on `pub use macros::*` should explain that `[macro_export]` macros don't need to be exported.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 (4f2f477fd 2024-10-23)
binary: rustc
commit-hash: 4f2f477fded0a47b21ed3f6aeddeafa5db8bf518
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning from the Rust code in src/lib.rs and compare the current and desired diagnostics. Start by tracing the unused_imports diagnostic for a pub use of a #[macro_export] macro, then add regression coverage for this case. Done means the warning includes the explanatory note shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100