mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
13 lines
605 B
Rust
13 lines
605 B
Rust
#![feature(plugin)]
|
|
#![plugin(clippy)]
|
|
|
|
#[allow(if_same_then_else)]
|
|
#[deny(needless_bool)]
|
|
fn main() {
|
|
let x = true;
|
|
if x { true } else { true }; //~ERROR this if-then-else expression will always return true
|
|
if x { false } else { false }; //~ERROR this if-then-else expression will always return false
|
|
if x { true } else { false }; //~ERROR you can reduce this if-then-else expression to just `x`
|
|
if x { false } else { true }; //~ERROR you can reduce this if-then-else expression to just `!x`
|
|
if x { x } else { false }; // would also be questionable, but we don't catch this yet
|
|
}
|