You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does not work to prevent clippy warning for same.
(Not sure if clippy warnings use compiled code or just raw code; if latter perhaps ordering of run is relevant - with expect notation being applied to code that's been optimized away?)
fnmain(){// unused attribute `expect`// `#[warn(unused_attributes)]` on by default#[expect(clippy::assertions_on_constants)]assert!(true);// `assert!(true)` will be optimized out by the compiler// remove it// for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants// `#[warn(clippy::assertions_on_constants)]` on by default}
I expected to see this happen:
the expect annotation of clippy warning prevent the clippy warning
Instead, this happened:
clippy warning remained and a new clippy warning mentioning that the expect had no effect
On further investigation this appears to be related to the currently open issue: rust-clippy/issues/10355
Looking at the clippy warning in terminal gave additional context:
note: the built-in attribute `expect` will be ignored, since it's applied to the macro invocation `assert` --> src/bin/min_example.rs:5:9 |5 | assert!(true); | ^^^^^^ = note: `#[warn(unused_attributes)]` on by default
The underlying issue then appears to simple be that attributes are not applied to macros.
I'll leave this here for someone else to close as redundant with the above issue (10355), just in case.
A workaround is simple to apply the #[expect(...)] to brackets {...} around the macro:
Summary
#[expect(clippy::assertions_on_constants)]
Does not work to prevent clippy warning for same.
(Not sure if clippy warnings use compiled code or just raw code; if latter perhaps ordering of run is relevant - with expect notation being applied to code that's been optimized away?)
e.g.
Reproducer
I tried this code:
I expected to see this happen:
the expect annotation of clippy warning prevent the clippy warning
Instead, this happened:
clippy warning remained and a new clippy warning mentioning that the expect had no effect
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: