Split up booleans
ui test
This commit is contained in:
parent
73e525019d
commit
3885033e5f
@ -1,244 +0,0 @@
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:10:13
|
||||
|
|
||||
LL | let _ = a && b || a;
|
||||
| ^^^^^^^^^^^ help: it would look like the following: `a`
|
||||
|
|
||||
= note: `-D clippy::logic-bug` implied by `-D warnings`
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:10:18
|
||||
|
|
||||
LL | let _ = a && b || a;
|
||||
| ^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:12:13
|
||||
|
|
||||
LL | let _ = !true;
|
||||
| ^^^^^ help: try: `false`
|
||||
|
|
||||
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:13:13
|
||||
|
|
||||
LL | let _ = !false;
|
||||
| ^^^^^^ help: try: `true`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:14:13
|
||||
|
|
||||
LL | let _ = !!a;
|
||||
| ^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:15:13
|
||||
|
|
||||
LL | let _ = false && a;
|
||||
| ^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:15:22
|
||||
|
|
||||
LL | let _ = false && a;
|
||||
| ^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:16:13
|
||||
|
|
||||
LL | let _ = false || a;
|
||||
| ^^^^^^^^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:21:13
|
||||
|
|
||||
LL | let _ = !(!a && b);
|
||||
| ^^^^^^^^^^ help: try: `a || !b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:22:13
|
||||
|
|
||||
LL | let _ = !(!a || b);
|
||||
| ^^^^^^^^^^ help: try: `a && !b`
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:32:13
|
||||
|
|
||||
LL | let _ = a == b && a != b;
|
||||
| ^^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:32:13
|
||||
|
|
||||
LL | let _ = a == b && a != b;
|
||||
| ^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:33:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b && c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b || c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:34:13
|
||||
|
|
||||
LL | let _ = a == b || c == 5 || a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b || c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b && c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:35:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && b == a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b && c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b || c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:36:13
|
||||
|
|
||||
LL | let _ = a < b && a >= b;
|
||||
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:36:13
|
||||
|
|
||||
LL | let _ = a < b && a >= b;
|
||||
| ^^^^^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:37:13
|
||||
|
|
||||
LL | let _ = a > b && a <= b;
|
||||
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:37:13
|
||||
|
|
||||
LL | let _ = a > b && a <= b;
|
||||
| ^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:39:13
|
||||
|
|
||||
LL | let _ = a != b || !(a != b || c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a != b || c != d;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a == b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:40:13
|
||||
|
|
||||
LL | let _ = a != b && !(a != b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a != b && c != d;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a == b || c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:48:13
|
||||
|
|
||||
LL | let _ = !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:50:13
|
||||
|
|
||||
LL | let _ = !a.is_none();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_some()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:52:13
|
||||
|
|
||||
LL | let _ = !b.is_err();
|
||||
| ^^^^^^^^^^^ help: try: `b.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:54:13
|
||||
|
|
||||
LL | let _ = !b.is_ok();
|
||||
| ^^^^^^^^^^ help: try: `b.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:56:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() && !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:57:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() || !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:58:26
|
||||
|
|
||||
LL | let _ = !(!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:59:25
|
||||
|
|
||||
LL | let _ = (!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:60:23
|
||||
|
|
||||
LL | let _ = !c ^ c || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:132:8
|
||||
|
|
||||
LL | if !res.is_ok() {}
|
||||
| ^^^^^^^^^^^^ help: try: `res.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:133:8
|
||||
|
|
||||
LL | if !res.is_err() {}
|
||||
| ^^^^^^^^^^^^^ help: try: `res.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:136:8
|
||||
|
|
||||
LL | if !res.is_some() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:137:8
|
||||
|
|
||||
LL | if !res.is_none() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_some()`
|
||||
|
||||
error: aborting due to 29 previous errors
|
||||
|
26
tests/ui/logic_bug.rs
Normal file
26
tests/ui/logic_bug.rs
Normal file
@ -0,0 +1,26 @@
|
||||
#![allow(unused, clippy::many_single_char_names)]
|
||||
#![warn(clippy::logic_bug)]
|
||||
|
||||
fn main() {
|
||||
let a: bool = unimplemented!();
|
||||
let b: bool = unimplemented!();
|
||||
let c: bool = unimplemented!();
|
||||
let d: bool = unimplemented!();
|
||||
let e: bool = unimplemented!();
|
||||
let _ = a && b || a;
|
||||
let _ = !(a && b);
|
||||
let _ = false && a;
|
||||
// don't lint on cfgs
|
||||
let _ = cfg!(you_shall_not_not_pass) && a;
|
||||
let _ = a || !b || !c || !d || !e;
|
||||
let _ = !(a && b || c);
|
||||
}
|
||||
|
||||
fn equality_stuff() {
|
||||
let a: i32 = unimplemented!();
|
||||
let b: i32 = unimplemented!();
|
||||
let _ = a == b && a != b;
|
||||
let _ = a < b && a >= b;
|
||||
let _ = a > b && a <= b;
|
||||
let _ = a > b && a == b;
|
||||
}
|
63
tests/ui/logic_bug.stderr
Normal file
63
tests/ui/logic_bug.stderr
Normal file
@ -0,0 +1,63 @@
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/logic_bug.rs:10:13
|
||||
|
|
||||
LL | let _ = a && b || a;
|
||||
| ^^^^^^^^^^^ help: it would look like the following: `a`
|
||||
|
|
||||
= note: `-D clippy::logic-bug` implied by `-D warnings`
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/logic_bug.rs:10:18
|
||||
|
|
||||
LL | let _ = a && b || a;
|
||||
| ^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/logic_bug.rs:12:13
|
||||
|
|
||||
LL | let _ = false && a;
|
||||
| ^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/logic_bug.rs:12:22
|
||||
|
|
||||
LL | let _ = false && a;
|
||||
| ^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/logic_bug.rs:22:13
|
||||
|
|
||||
LL | let _ = a == b && a != b;
|
||||
| ^^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/logic_bug.rs:22:13
|
||||
|
|
||||
LL | let _ = a == b && a != b;
|
||||
| ^^^^^^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/logic_bug.rs:23:13
|
||||
|
|
||||
LL | let _ = a < b && a >= b;
|
||||
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/logic_bug.rs:23:13
|
||||
|
|
||||
LL | let _ = a < b && a >= b;
|
||||
| ^^^^^
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/logic_bug.rs:24:13
|
||||
|
|
||||
LL | let _ = a > b && a <= b;
|
||||
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/logic_bug.rs:24:13
|
||||
|
|
||||
LL | let _ = a > b && a <= b;
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
52
tests/ui/nonminimal_bool.rs
Normal file
52
tests/ui/nonminimal_bool.rs
Normal file
@ -0,0 +1,52 @@
|
||||
#![allow(unused, clippy::many_single_char_names)]
|
||||
#![warn(clippy::nonminimal_bool)]
|
||||
|
||||
fn main() {
|
||||
let a: bool = unimplemented!();
|
||||
let b: bool = unimplemented!();
|
||||
let c: bool = unimplemented!();
|
||||
let d: bool = unimplemented!();
|
||||
let e: bool = unimplemented!();
|
||||
let _ = !true;
|
||||
let _ = !false;
|
||||
let _ = !!a;
|
||||
let _ = false || a;
|
||||
// don't lint on cfgs
|
||||
let _ = cfg!(you_shall_not_not_pass) && a;
|
||||
let _ = a || !b || !c || !d || !e;
|
||||
let _ = !(!a && b);
|
||||
let _ = !(!a || b);
|
||||
let _ = !a && !(b && c);
|
||||
}
|
||||
|
||||
fn equality_stuff() {
|
||||
let a: i32 = unimplemented!();
|
||||
let b: i32 = unimplemented!();
|
||||
let c: i32 = unimplemented!();
|
||||
let d: i32 = unimplemented!();
|
||||
let _ = a == b && c == 5 && a == b;
|
||||
let _ = a == b || c == 5 || a == b;
|
||||
let _ = a == b && c == 5 && b == a;
|
||||
let _ = a != b || !(a != b || c == d);
|
||||
let _ = a != b && !(a != b && c == d);
|
||||
}
|
||||
|
||||
fn issue3847(a: u32, b: u32) -> bool {
|
||||
const THRESHOLD: u32 = 1_000;
|
||||
|
||||
if a < THRESHOLD && b >= THRESHOLD || a >= THRESHOLD && b < THRESHOLD {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn issue4548() {
|
||||
fn f(_i: u32, _j: u32) -> u32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
if i != j && f(i, j) != 0 || i == j && f(i, j) != 1 {}
|
||||
}
|
111
tests/ui/nonminimal_bool.stderr
Normal file
111
tests/ui/nonminimal_bool.stderr
Normal file
@ -0,0 +1,111 @@
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:10:13
|
||||
|
|
||||
LL | let _ = !true;
|
||||
| ^^^^^ help: try: `false`
|
||||
|
|
||||
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:11:13
|
||||
|
|
||||
LL | let _ = !false;
|
||||
| ^^^^^^ help: try: `true`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:12:13
|
||||
|
|
||||
LL | let _ = !!a;
|
||||
| ^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:13:13
|
||||
|
|
||||
LL | let _ = false || a;
|
||||
| ^^^^^^^^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:17:13
|
||||
|
|
||||
LL | let _ = !(!a && b);
|
||||
| ^^^^^^^^^^ help: try: `a || !b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:18:13
|
||||
|
|
||||
LL | let _ = !(!a || b);
|
||||
| ^^^^^^^^^^ help: try: `a && !b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:19:13
|
||||
|
|
||||
LL | let _ = !a && !(b && c);
|
||||
| ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:27:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b && c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b || c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:28:13
|
||||
|
|
||||
LL | let _ = a == b || c == 5 || a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b || c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b && c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:29:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && b == a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a == b && c == 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a != b || c != 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:30:13
|
||||
|
|
||||
LL | let _ = a != b || !(a != b || c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a != b || c != d;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a == b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool.rs:31:13
|
||||
|
|
||||
LL | let _ = a != b && !(a != b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | let _ = a != b && c != d;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _ = !(a == b || c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
@ -1,46 +1,6 @@
|
||||
#![warn(clippy::nonminimal_bool, clippy::logic_bug)]
|
||||
#![allow(unused, clippy::many_single_char_names)]
|
||||
#![warn(clippy::nonminimal_bool)]
|
||||
|
||||
#[allow(unused, clippy::many_single_char_names)]
|
||||
fn main() {
|
||||
let a: bool = unimplemented!();
|
||||
let b: bool = unimplemented!();
|
||||
let c: bool = unimplemented!();
|
||||
let d: bool = unimplemented!();
|
||||
let e: bool = unimplemented!();
|
||||
let _ = a && b || a;
|
||||
let _ = !(a && b);
|
||||
let _ = !true;
|
||||
let _ = !false;
|
||||
let _ = !!a;
|
||||
let _ = false && a;
|
||||
let _ = false || a;
|
||||
// don't lint on cfgs
|
||||
let _ = cfg!(you_shall_not_not_pass) && a;
|
||||
let _ = a || !b || !c || !d || !e;
|
||||
let _ = !(a && b || c);
|
||||
let _ = !(!a && b);
|
||||
let _ = !(!a || b);
|
||||
}
|
||||
|
||||
#[allow(unused, clippy::many_single_char_names)]
|
||||
fn equality_stuff() {
|
||||
let a: i32 = unimplemented!();
|
||||
let b: i32 = unimplemented!();
|
||||
let c: i32 = unimplemented!();
|
||||
let d: i32 = unimplemented!();
|
||||
let e: i32 = unimplemented!();
|
||||
let _ = a == b && a != b;
|
||||
let _ = a == b && c == 5 && a == b;
|
||||
let _ = a == b || c == 5 || a == b;
|
||||
let _ = a == b && c == 5 && b == a;
|
||||
let _ = a < b && a >= b;
|
||||
let _ = a > b && a <= b;
|
||||
let _ = a > b && a == b;
|
||||
let _ = a != b || !(a != b || c == d);
|
||||
let _ = a != b && !(a != b && c == d);
|
||||
}
|
||||
|
||||
#[allow(unused, clippy::many_single_char_names)]
|
||||
fn methods_with_negation() {
|
||||
let a: Option<i32> = unimplemented!();
|
||||
let b: Result<i32, i32> = unimplemented!();
|
||||
@ -147,22 +107,4 @@ fn dont_warn_for_negated_partial_ord_comparison() {
|
||||
let _ = !(a >= b);
|
||||
}
|
||||
|
||||
fn issue3847(a: u32, b: u32) -> bool {
|
||||
const THRESHOLD: u32 = 1_000;
|
||||
|
||||
if a < THRESHOLD && b >= THRESHOLD || a >= THRESHOLD && b < THRESHOLD {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn issue4548() {
|
||||
fn f(_i: u32, _j: u32) -> u32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
if i != j && f(i, j) != 0 || i == j && f(i, j) != 1 {}
|
||||
}
|
||||
fn main() {}
|
82
tests/ui/nonminimal_bool_methods.stderr
Normal file
82
tests/ui/nonminimal_bool_methods.stderr
Normal file
@ -0,0 +1,82 @@
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:8:13
|
||||
|
|
||||
LL | let _ = !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
|
||||
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:10:13
|
||||
|
|
||||
LL | let _ = !a.is_none();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_some()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:12:13
|
||||
|
|
||||
LL | let _ = !b.is_err();
|
||||
| ^^^^^^^^^^^ help: try: `b.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:14:13
|
||||
|
|
||||
LL | let _ = !b.is_ok();
|
||||
| ^^^^^^^^^^ help: try: `b.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:16:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() && !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:17:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() || !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:18:26
|
||||
|
|
||||
LL | let _ = !(!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:19:25
|
||||
|
|
||||
LL | let _ = (!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:20:23
|
||||
|
|
||||
LL | let _ = !c ^ c || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:92:8
|
||||
|
|
||||
LL | if !res.is_ok() {}
|
||||
| ^^^^^^^^^^^^ help: try: `res.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:93:8
|
||||
|
|
||||
LL | if !res.is_err() {}
|
||||
| ^^^^^^^^^^^^^ help: try: `res.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:96:8
|
||||
|
|
||||
LL | if !res.is_some() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/nonminimal_bool_methods.rs:97:8
|
||||
|
|
||||
LL | if !res.is_none() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_some()`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user