rust-clippy/tests/compile-fail/bool_comparison.rs

24 lines
745 B
Rust
Raw Normal View History

#![feature(plugin)]
#![plugin(clippy)]
#[deny(bool_comparison)]
fn main() {
let x = true;
if x == true { "yes" } else { "no" };
//~^ ERROR equality checks against booleans are unnecesary
//~| HELP try simplifying it:
//~| SUGGESTION x
if x == false { "yes" } else { "no" };
//~^ ERROR equality checks against booleans are unnecesary
//~| HELP try simplifying it:
//~| SUGGESTION !x
if true == x { "yes" } else { "no" };
//~^ ERROR equality checks against booleans are unnecesary
//~| HELP try simplifying it:
//~| SUGGESTION x
if false == x { "yes" } else { "no" };
//~^ ERROR equality checks against booleans are unnecesary
//~| HELP try simplifying it:
//~| SUGGESTION !x
}