2022-06-30 03:50:09 -05:00
|
|
|
#![feature(lint_reasons)]
|
2021-09-28 12:03:12 -05:00
|
|
|
#![allow(unused, clippy::diverging_sub_expression)]
|
2022-08-11 12:42:16 -05:00
|
|
|
#![warn(clippy::overly_complex_bool_expr)]
|
2020-01-13 16:41:11 -06:00
|
|
|
|
|
|
|
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;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2020-01-13 16:41:11 -06:00
|
|
|
let _ = !(a && b);
|
|
|
|
let _ = false && a;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2020-01-13 16:41:11 -06:00
|
|
|
// 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;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2020-01-13 16:41:11 -06:00
|
|
|
let _ = a < b && a >= b;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2020-01-13 16:41:11 -06:00
|
|
|
let _ = a > b && a <= b;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2020-01-13 16:41:11 -06:00
|
|
|
let _ = a > b && a == b;
|
|
|
|
}
|
2022-06-30 03:50:09 -05:00
|
|
|
|
|
|
|
fn check_expect() {
|
|
|
|
let a: i32 = unimplemented!();
|
|
|
|
let b: i32 = unimplemented!();
|
2022-08-11 12:42:16 -05:00
|
|
|
#[expect(clippy::overly_complex_bool_expr)]
|
2022-06-30 03:50:09 -05:00
|
|
|
let _ = a < b && a >= b;
|
|
|
|
}
|
2024-06-13 05:30:48 -05:00
|
|
|
|
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
fn check_never_type() {
|
|
|
|
loop {
|
|
|
|
_ = (break) || true;
|
|
|
|
}
|
|
|
|
loop {
|
|
|
|
_ = (return) || true;
|
|
|
|
}
|
|
|
|
}
|