-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
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.
#[cfg(test)]
mod tests {
#[test]
fn test_truth() {
#[expect(clippy::assertions_on_constants)]
assert!(true);
}
}
Reproducer
I tried this code:
fn main() {
// 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
Version
rustc 1.85.0-nightly (28fc2ba71 2024-11-24)
binary: rustc
commit-hash: 28fc2ba7142654fa6e654926f96ff913027b200e
commit-date: 2024-11-24
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.4
Note, if relevant:
cargo.toml also contains:
cargo-features = ["edition2024"]
#...
[package]
#...
edition = "2024"
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing