Open
Description
Summary
rust-lang/rust#116098 removes the illegal_floating_point_literal_pattern
lint. A float literal in a match
expression is semantically equivalent to ==
and, if this is merged, I think it makes sense to suggest a guard.
If this lint is kept, this should be closed
Lint Name
float_cmp
Reproducer
I tried this code:
#![warn(clippy::float_cmp)]
fn main() {
let x = 1.2331f64;
// prints `a`
match x {
1.23f64 => println!("a"),
_ => {},
}
}
I expected to see this happen:
Clippy suggests:
#![warn(clippy::float_cmp)]
fn main() {
let x = 1.2331f64;
// prints nothing
match x {
x if (x - 1.23f64).abs() < f64::EPSILON => println!("a"),
_ => {},
}
}
Instead, this happened: No warning (from clippy)
Version
rustc 1.74.0-nightly (bdb0fa3ee 2023-09-19)
binary: rustc
commit-hash: bdb0fa3ee5ffb4cc1a1b53cbe8344a2b83b1ae2a
commit-date: 2023-09-19
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0