Skip to content

comparison_chain false positive for f64 #4924

@youknowone

Description

@youknowone
$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions