rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

Feature request: configuration to allow `clippy::allow_attributes` inside macro definitions/expansions

Open BatmanAoD opened this issue 3 months ago • 4 comments

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_attributes within a macro definition or expansion
  • ...or, probably more complicated: treat expect within a macro as fulfilled if any expansion triggers the lint

BatmanAoD avatar Aug 14 '26 19:08 BatmanAoD

Just ran into this myself. Would be helpful if the allow_attributes lint defaulted to being allowed inside macro definitions.

(Optionally, it might be nice if there were a way to further restrict what can be allowed in macros, but that can come later.)

joshtriplett avatar Sep 25 '26 15:09 joshtriplett

@rustbot label "good first issue"

We have documentation about how macros can be anoying and this is usually something fairly striaghtforward to solve. 😉

https://doc.rust-lang.org/clippy/development/macro_expansions.html

CommanderStorm avatar Sep 25 '26 15:09 CommanderStorm

@rustbot claim

arthurmm avatar Sep 25 '26 19:09 arthurmm

@rustbot claim

jny0444 avatar Oct 10 '26 05:10 jny0444