2023-07-27 11:40:22 +00:00
|
|
|
#![feature(lint_reasons)]
|
|
|
|
#![allow(unused, clippy::diverging_sub_expression)]
|
|
|
|
#![warn(clippy::overly_complex_bool_expr)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a: bool = unimplemented!();
|
|
|
|
let b: bool = unimplemented!();
|
|
|
|
let c: bool = unimplemented!();
|
|
|
|
let d: bool = unimplemented!();
|
|
|
|
let e: bool = unimplemented!();
|
|
|
|
let _ = a;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2023-07-27 11:40:22 +00:00
|
|
|
let _ = !(a && b);
|
|
|
|
let _ = false;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2023-07-27 11:40:22 +00: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 _ = false;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2023-07-27 11:40:22 +00:00
|
|
|
let _ = false;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2023-07-27 11:40:22 +00:00
|
|
|
let _ = false;
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
2023-07-27 11:40:22 +00:00
|
|
|
let _ = a > b && a == b;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_expect() {
|
|
|
|
let a: i32 = unimplemented!();
|
|
|
|
let b: i32 = unimplemented!();
|
|
|
|
#[expect(clippy::overly_complex_bool_expr)]
|
|
|
|
let _ = a < b && a >= b;
|
|
|
|
}
|
2024-04-21 11:53:47 +00:00
|
|
|
|
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
fn check_never_type() {
|
|
|
|
loop {
|
|
|
|
_ = (break) || true;
|
|
|
|
}
|
|
|
|
loop {
|
|
|
|
_ = (return) || true;
|
|
|
|
}
|
|
|
|
}
|