fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![warn(clippy::needless_bitwise_bool)] 2 3fn returns_bool() -> bool { 4 true 5} 6 7const fn const_returns_bool() -> bool { 8 false 9} 10 11fn main() { 12 let (x, y) = (false, true); 13 if x & y { 14 println!("true") 15 } 16 if returns_bool() & x { 17 println!("true") 18 } 19 if !returns_bool() & returns_bool() { 20 println!("true") 21 } 22 if y && !x { 23 println!("true") 24 } 25 26 // BELOW: lints we hope to catch as `Expr::can_have_side_effects` improves. 27 if y & !const_returns_bool() { 28 println!("true") // This is a const function, in an UnOp 29 } 30 31 if y & "abcD".is_empty() { 32 println!("true") // This is a const method call 33 } 34 35 if y & (0 < 1) { 36 println!("true") // This is a BinOp with no side effects 37 } 38}