rust-lang / rust-lang/rust-clippy
Allow float comparison with zero
Open
Nobody has claimed this yet.
C-bug
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
cargo clippy -V: clippy 0.0.212 (d61b254 2019-02-19)
Clippy should allow float comparison with zero. The current behavior seems to be a regression as this has apparently already been reported and fixed in #165/#1142.
error: strict comparison of f32 or f64
--> tests/test_datetime.rs:125:5
|
125 | assert_eq!(offset, 0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::float_cmp)] on by default
note: std::f32::EPSILON and std::f64::EPSILON are available.
--> tests/test_datetime.rs:125:5
|
125 | assert_eq!(offset, 0f32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/test_datetime.rs and reproduce the diagnostic with cargo clippy, then trace the float_cmp lint behavior. Done means the shown comparison with zero no longer emits the error, with regression coverage for the corrected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100