-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
In spite of rustc considering floating point literals a deprecated match pattern, clippy emits a "redundant guard" warning for x if x == <float literal>
and instead suggests replacing that with the literal itself.
Lint Name
redundant_guards
Reproducer
I tried this code:
fn main() {
match 0.1 {
x if x == 0.0 => todo!(),
_ => todo!()
}
}
I saw this happen:
warning: redundant guard
--> test.rs:3:14
|
3 | x if x == 0.0 => todo!(),
| ^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guards
= note: `#[warn(clippy::redundant_guards)]` on by default
help: try
|
3 - x if x == 0.0 => todo!(),
3 + 0.0 => todo!(),
|
warning: 1 warning emitted
I expected to see this happen:
no warnings from clippy
Version
rustc 1.73.0-nightly (03a119b0b 2023-08-07)
binary: rustc
commit-hash: 03a119b0b0e310d22d94399b24ed030056050f13
commit-date: 2023-08-07
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 16.0.5
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have