3 #![deny(nonminimal_bool, logic_bug)]
5 #[allow(unused, many_single_char_names)]
7 let a: bool = unimplemented!();
8 let b: bool = unimplemented!();
9 let c: bool = unimplemented!();
10 let d: bool = unimplemented!();
11 let e: bool = unimplemented!();
12 let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
13 //~| HELP this expression can be optimized out
14 //~| HELP it would look like the following
15 //~| SUGGESTION let _ = a;
17 let _ = !true; //~ ERROR this boolean expression can be simplified
19 //~| SUGGESTION let _ = false;
20 let _ = !false; //~ ERROR this boolean expression can be simplified
22 //~| SUGGESTION let _ = true;
23 let _ = !!a; //~ ERROR this boolean expression can be simplified
25 //~| SUGGESTION let _ = a;
27 let _ = false && a; //~ ERROR this boolean expression contains a logic bug
28 //~| HELP this expression can be optimized out
29 //~| HELP it would look like the following
30 //~| SUGGESTION let _ = false;
32 let _ = false || a; //~ ERROR this boolean expression can be simplified
34 //~| SUGGESTION let _ = a;
37 let _ = cfg!(you_shall_not_not_pass) && a;
39 let _ = a || !b || !c || !d || !e;
41 let _ = !(a && b || c);
43 let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
45 //~| SUGGESTION let _ = !b || a;
48 #[allow(unused, many_single_char_names)]
50 let a: i32 = unimplemented!();
51 let b: i32 = unimplemented!();
52 let c: i32 = unimplemented!();
53 let d: i32 = unimplemented!();
54 let e: i32 = unimplemented!();
55 let _ = a == b && a != b; //~ ERROR this boolean expression contains a logic bug
56 //~| HELP this expression can be optimized out
57 //~| HELP it would look like the following
58 //~| SUGGESTION let _ = false;
59 let _ = a == b && c == 5 && a == b; //~ ERROR this boolean expression can be simplified
61 //~| SUGGESTION let _ = a == b && c == 5;
62 let _ = a == b && c == 5 && b == a; //~ ERROR this boolean expression can be simplified
64 //~| SUGGESTION let _ = a == b && c == 5;
66 //~| SUGGESTION let _ = !(c != 5 || a != b);
67 let _ = a < b && a >= b; //~ ERROR this boolean expression contains a logic bug
68 //~| HELP this expression can be optimized out
69 //~| HELP it would look like the following
70 //~| SUGGESTION let _ = false;
71 let _ = a > b && a <= b; //~ ERROR this boolean expression contains a logic bug
72 //~| HELP this expression can be optimized out
73 //~| HELP it would look like the following
74 //~| SUGGESTION let _ = false;
75 let _ = a > b && a == b;
77 let _ = a != b || !(a != b || c == d); //~ ERROR this boolean expression can be simplified
79 //~| SUGGESTION let _ = c != d || a != b;
81 //~| SUGGESTION let _ = !(a == b && c == d);