2016-03-23 13:50:47 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
2016-03-24 09:45:24 +00:00
|
|
|
#![deny(nonminimal_bool, logic_bug)]
|
2016-03-23 13:50:47 +00:00
|
|
|
|
2016-03-24 14:37:17 +00:00
|
|
|
#[allow(unused, many_single_char_names)]
|
2016-03-23 13:50:47 +00:00
|
|
|
fn main() {
|
|
|
|
let a: bool = unimplemented!();
|
|
|
|
let b: bool = unimplemented!();
|
2016-03-24 09:54:48 +00:00
|
|
|
let c: bool = unimplemented!();
|
2016-03-24 14:37:17 +00:00
|
|
|
let d: bool = unimplemented!();
|
|
|
|
let e: bool = unimplemented!();
|
2016-03-24 09:45:24 +00:00
|
|
|
let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP this expression can be optimized out
|
|
|
|
//~| HELP it would look like the following
|
|
|
|
//~| SUGGESTION let _ = a;
|
2016-03-24 09:54:48 +00:00
|
|
|
let _ = !(a && b);
|
2016-03-23 13:50:47 +00:00
|
|
|
let _ = !true; //~ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = false;
|
2016-03-23 13:50:47 +00:00
|
|
|
let _ = !false; //~ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = true;
|
2016-03-23 13:50:47 +00:00
|
|
|
let _ = !!a; //~ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = a;
|
2016-03-24 08:36:46 +00:00
|
|
|
|
2016-03-24 09:45:24 +00:00
|
|
|
let _ = false && a; //~ ERROR this boolean expression contains a logic bug
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP this expression can be optimized out
|
|
|
|
//~| HELP it would look like the following
|
|
|
|
//~| SUGGESTION let _ = false;
|
2016-03-24 08:36:46 +00:00
|
|
|
|
|
|
|
let _ = false || a; //~ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = a;
|
2016-03-24 08:37:16 +00:00
|
|
|
|
|
|
|
// don't lint on cfgs
|
|
|
|
let _ = cfg!(you_shall_not_not_pass) && a;
|
2016-03-24 09:54:48 +00:00
|
|
|
|
2016-03-24 14:37:17 +00:00
|
|
|
let _ = a || !b || !c || !d || !e;
|
|
|
|
|
2016-03-24 09:54:48 +00:00
|
|
|
let _ = !(a && b || c);
|
2016-03-24 14:37:17 +00:00
|
|
|
|
|
|
|
let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = !b || a;
|
2016-03-23 13:50:47 +00:00
|
|
|
}
|
2016-03-24 14:44:08 +00:00
|
|
|
|
|
|
|
#[allow(unused, 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!();
|
2016-06-07 16:32:26 +00:00
|
|
|
let _ = a == b && a != b;
|
|
|
|
//~^ ERROR this boolean expression contains a logic bug
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP this expression can be optimized out
|
|
|
|
//~| HELP it would look like the following
|
|
|
|
//~| SUGGESTION let _ = false;
|
2016-06-07 16:32:26 +00:00
|
|
|
let _ = a == b && c == 5 && a == b;
|
|
|
|
//~^ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = a == b && c == 5;
|
2016-06-07 16:32:26 +00:00
|
|
|
//~| HELP try
|
|
|
|
//~| SUGGESTION let _ = !(c != 5 || a != b);
|
|
|
|
let _ = a == b && c == 5 && b == a;
|
|
|
|
//~^ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| SUGGESTION let _ = a == b && c == 5;
|
|
|
|
//~| HELP try
|
2016-03-29 15:18:47 +00:00
|
|
|
//~| SUGGESTION let _ = !(c != 5 || a != b);
|
2016-06-07 16:32:26 +00:00
|
|
|
let _ = a < b && a >= b;
|
|
|
|
//~^ ERROR this boolean expression contains a logic bug
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP this expression can be optimized out
|
|
|
|
//~| HELP it would look like the following
|
|
|
|
//~| SUGGESTION let _ = false;
|
2016-06-07 16:32:26 +00:00
|
|
|
let _ = a > b && a <= b;
|
|
|
|
//~^ ERROR this boolean expression contains a logic bug
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP this expression can be optimized out
|
|
|
|
//~| HELP it would look like the following
|
|
|
|
//~| SUGGESTION let _ = false;
|
2016-03-24 14:44:08 +00:00
|
|
|
let _ = a > b && a == b;
|
2016-03-29 08:44:35 +00:00
|
|
|
|
2016-06-07 16:32:26 +00:00
|
|
|
let _ = a != b || !(a != b || c == d);
|
|
|
|
//~^ ERROR this boolean expression can be simplified
|
2016-06-05 19:05:28 +00:00
|
|
|
//~| HELP try
|
2016-03-29 15:18:47 +00:00
|
|
|
//~| SUGGESTION let _ = c != d || a != b;
|
2016-03-29 14:55:38 +00:00
|
|
|
//~| HELP try
|
2016-03-29 15:18:47 +00:00
|
|
|
//~| SUGGESTION let _ = !(a == b && c == d);
|
2016-03-24 14:44:08 +00:00
|
|
|
}
|