rust-clippy/tests/ui/if_not_else.rs

32 lines
567 B
Rust
Raw Normal View History

2018-07-28 15:34:52 +00:00
#![warn(clippy::all)]
#![warn(clippy::if_not_else)]
fn foo() -> bool {
unimplemented!()
}
2018-12-09 22:26:16 +00:00
fn bla() -> bool {
unimplemented!()
}
fn main() {
2017-02-08 13:58:07 +00:00
if !bla() {
//~^ ERROR: unnecessary boolean `not` operation
println!("Bugs");
} else {
println!("Bunny");
}
2017-02-08 13:58:07 +00:00
if 4 != 5 {
//~^ ERROR: unnecessary `!=` operation
println!("Bugs");
} else {
println!("Bunny");
}
if !foo() {
println!("Foo");
} else if !bla() {
println!("Bugs");
} else {
println!("Bunny");
}
}