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

comparison_chain false positive for f64 #4924

Closed
youknowone opened this issue Dec 20, 2019 · 2 comments
Closed

comparison_chain false positive for f64 #4924

youknowone opened this issue Dec 20, 2019 · 2 comments

Comments

@youknowone
Copy link
Contributor

youknowone commented Dec 20, 2019

$ cargo clippy -V
clippy 0.0.212 (c8e3cfbd 2019-10-28)

The below happens when modulus is a f64 vairalbe.

warning: `if` chain can be rewritten with `match`
   --> vm/src/stdlib/math.rs:327:9
    |
327 | /         if modulus < c {
328 | |             r = modulus;
329 | |         } else if modulus > c {
330 | |             r = -c;
331 | |         } else {
332 | |             r = modulus - 2.0 * fmod(0.5 * (absx - modulus), absy);
333 | |         }
    | |_________^
    |
    = note: `#[warn(clippy::comparison_chain)]` on by default
    = help: Consider rewriting the `if` chain to use `cmp` and `match`.
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain

The link in help is not helpful for f64. So I guess this is a false positive or lack of help document

@ghost
Copy link

ghost commented Dec 21, 2019

I can't reproduce this error. The lint checks that the type implements Ord so this shouldn't be happening. Can you provide an example on the rust playground?

@flip1995
Copy link
Member

The Ord thing was fixed on Nov 18: #4827

Closing this issue, since it's already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants