mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
#![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 && b || a;
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
|
let _ = !(a && b);
|
|
let _ = false && a;
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
|
// 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;
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
|
let _ = a < b && a >= b;
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
|
let _ = a > b && a <= b;
|
|
//~^ ERROR: this boolean expression contains a logic bug
|
|
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;
|
|
}
|