rust-lang / rust-lang/rust-clippy
Feature request: configuration to allow `clippy::allow_attributes` inside macro definitions/expansions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
In general, I find expect preferable to allow, but in a macro definition, it's sometimes the case that a lint will only trigger on some expansions rather than all expansions, which makes it necessary to use allow rather than expect.
The current workaround I use is something like this:
#[expect(clippy::allow_attributes, reason="macro")]
#[allow(<lint>, reason = "...")]
...but it would be nice if there were a configuration option to globally do one of the following:
- Never trigger
allow_attributeswithin a macro definition or expansion - ...or, probably more complicated: treat
expectwithin a macro as fulfilled if any expansion triggers the lint
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
Start by locating the implementation and tests for the clippy::allow_attributes lint, then trace how macro definitions and expansions are classified. Compare the two proposed configuration behaviors and establish tests covering allow and expect in macros; done means the selected behavior is configurable and verified without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100