fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![allow(unused)] 2#![warn(clippy::needless_else)] 3#![allow(clippy::suspicious_else_formatting)] 4 5macro_rules! mac { 6 ($test:expr) => { 7 if $test { 8 println!("Test successful!"); 9 } else { 10 } 11 }; 12} 13 14macro_rules! empty_expansion { 15 () => {}; 16} 17 18fn main() { 19 let b = std::hint::black_box(true); 20 21 if b { 22 println!("Foobar"); 23 } 24 25 if b { 26 println!("Foobar"); 27 } else { 28 // Do not lint because this comment might be important 29 } 30 31 if b { 32 println!("Foobar"); 33 } else 34 /* Do not lint because this comment might be important */ 35 { 36 } 37 38 // Do not lint because of the expression 39 let _ = if b { 1 } else { 2 }; 40 41 // Do not lint because inside a macro 42 mac!(b); 43 44 if b { 45 println!("Foobar"); 46 } else { 47 #[cfg(foo)] 48 "Do not lint cfg'd out code" 49 } 50 51 if b { 52 println!("Foobar"); 53 } else { 54 empty_expansion!(); 55 } 56}