Should importing a `#[macro_export] macro_rules!` macro trigger `unused_imports`?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#[macro_export]
macro_rules! owo {
() => {};
}
mod m {
use crate::owo;
owo!();
}
On stable, cargo check completes successfully. On Nightly, it produces a warning:
warning: unused import: `crate::owo`
--> src/lib.rs:6:9
|
6 | use crate::owo;
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
Nightly is correct in the sense that the import is, in fact, unnecessary, and the code builds with or without it. But I’m not sure whether this is a bug or not. I always put the import in because I like to think about modules and don’t like to think about the arcane macro_rules! scoping rules, but given that I can’t disable those rules this might be a losing battle…
Meta
rustc --version --verbose:
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8
rustc +nightly --version --verbose:
rustc 1.92.0-nightly (53a741fc4 2025-10-16)
binary: rustc
commit-hash: 53a741fc4b8cf2d8e7b1b2336ed8edf889db84f4
commit-date: 2025-10-16
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.3
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 with the provided src/lib.rs example using stable and nightly cargo check, and compare the unused_imports behavior. Start by investigating rustc's macro_rules! import and lint handling; done means establishing whether the nightly warning is intended and, if not, identifying the relevant compiler test or component to change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100