Skip to content

The suggestion of nonminimal_bool seems to be redundant. #3847

Closed
@koushiro

Description

@koushiro

clippy version:

clippy 0.0.212 (1b89724 2019-01-15)
clippy 0.0.212 (caccf8b 2019-03-03)

code:

       │ File: src/main.rs
───────┼────────────────────────────────────────────────────────────────────────────────
   1   │ const THRESHOLD: u32 = 1_000;
   2   │ 
   3   │ fn clippy_test(a: u32, b: u32) -> bool {
   4   │     if a < THRESHOLD && b >= THRESHOLD || a >= THRESHOLD && b < THRESHOLD {
   5   │         return false;
   6   │     }
   7   │     true
   8   │ }
   9   │ 
  10   │ fn main() {
  11   │     assert_eq!(clippy_test(100, 200), true);
  12   │     assert_eq!(clippy_test(1_100, 900), false);
  13   │ }

warning:

clippy-test-demo git:(master) ✗ cargo clippy
    Checking clippy-test-demo v0.1.0 (/home/koushiro/Code/clippy-test-demo)
warning: this boolean expression can be simplified
 --> src/main.rs:4:8
  |
4 |     if a < THRESHOLD && b >= THRESHOLD || a >= THRESHOLD && b < THRESHOLD {
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
help: try: `a < THRESHOLD && b >= THRESHOLD || a >= THRESHOLD && b < THRESHOLD`
  |
  = note: #[warn(clippy::nonminimal_bool)] on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/
master/index.html#nonminimal_bool

    Finished dev [unoptimized + debuginfo] target(s) in 0.42s

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions