Rust-clippy: Manual RangeInclusive implementation needs a space when using floats.

Created on 10 Nov 2020  路  2Comments  路  Source: rust-lang/rust-clippy

Clippy gave me this message:

warning: manual `!RangeInclusive::contains` implementation
   --> src\misc.rs:223:40
    |
223 |     if (log_p && p > 0.) || (!log_p && ((p < 0.) || (p > 1.))) {
    |                                        ^^^^^^^^^^^^^^^^^^^^^^ help: use: `!(0...=1.).contains(&p)`
    |
    = note: `#[warn(clippy::manual_range_contains)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains

But this !(0...=1.).contains(&p) is not valid,
it needs a space i.e. !(0. ..=1.).contains(&p).

I don't know how to report this in a better way, but here you go.

Meta

  • cargo clippy -V: e.g. clippy 0.0.212 (f455e46 2020-06-20)
  • rustc -Vv:
Microsoft Windows [Version 10.0.19041.572]
(c) 2020 Microsoft Corporation. All rights reserved.

[redacted]>cargo clippy -V
clippy 0.0.212 (1773f60e 2020-11-08)

[redacted]>rustc -Vv
rustc 1.49.0-nightly (1773f60ea 2020-11-08)
binary: rustc
commit-hash: 1773f60ea5d42e86b8fdf78d2fc5221ead222bc1
commit-date: 2020-11-08
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly

I'm not including a backtrace, as there was no panic to trace.

Thanks!

L-bug L-suggestion-causes-error

Most helpful comment

I will prepare a fix.

All 2 comments

@rustbot modify labels: +L-suggestion-causes-error

I will prepare a fix.

Was this page helpful?
0 / 5 - 0 ratings