Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow float comparison with zero #3804

Open
konstin opened this issue Feb 23, 2019 · 1 comment
Open

Allow float comparison with zero #3804

konstin opened this issue Feb 23, 2019 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@konstin
Copy link

konstin commented Feb 23, 2019

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)
@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Feb 24, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Feb 25, 2019

This might not even be a regression, but just a problem with assert_eq. Our const folder does not know about references, so &offset == &0 will still get linted about.

bors added a commit that referenced this issue Oct 9, 2020
allow refs in our constant folder

This helps with #3804 (but won't completely fix it).

---

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

3 participants