mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-19 03:54:40 +00:00
7aee04878f
(Did not touch strings.rs, which is fixed by @llogiq's PR)
13 lines
570 B
Rust
Executable File
13 lines
570 B
Rust
Executable File
#![feature(plugin)]
|
|
#![plugin(clippy)]
|
|
|
|
#[deny(needless_bool)]
|
|
fn main() {
|
|
let x = true;
|
|
if x { true } else { true }; //~ERROR your if-then-else expression will always return true
|
|
if x { false } else { false }; //~ERROR your if-then-else expression will always return false
|
|
if x { true } else { false }; //~ERROR you can reduce your if statement to its predicate
|
|
if x { false } else { true }; //~ERROR you can reduce your if statement to `!` + its predicate
|
|
if x { x } else { false }; // would also be questionable, but we don't catch this yet
|
|
}
|