rust-lang / rust-lang/rust-clippy
crate_in_macro_def warning even when decorated with #[allow(...)]
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
When running cargo clippy on a macro referencing crate, but with the reference decorated with the corresponding #[allow()] I still get a clippy warning for it.
An example is this commit: https://github.com/petekubiak/post-haste/commit/33112ddb1958c83a43343444bba3017d329c2ffe
Running cargo clippy shows the warning for line 48 of src/lib.rs (Interestingly it doesn't show for line 77 of the same file)
Lint Name
crate_in_macro_def
Reproducer
Checkout this commit https://github.com/petekubiak/post-haste/commit/33112ddb1958c83a43343444bba3017d329c2ffe
run cargo clippy in the repo root
(or alternatively nix develop --command cargo clippy)
The warning also shows up when the macro is used - running cargo clippy --example showcase on the same commit demonstrates this.
Version
rustc 1.89.0-nightly (ce7e97f73 2025-05-11)
binary: rustc
commit-hash: ce7e97f7371af47e0786f74aa169f6ac9473ff4e
commit-date: 2025-05-11
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4
Additional Labels
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
Check out commit 33112ddb1958c83a43343444bba3017d329c2ffe in the linked post-haste repository and run cargo clippy, or cargo clippy --example showcase. Start by examining the crate_in_macro_def lint behavior for the #[allow(...)] case. Done means the corresponding allowance suppresses the warning both at the macro definition and when the macro is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100