mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
39c8f84f3b
This splits up the needless_bool tests into `fixable.rs` and `simple.rs`. `simple.rs` contains the code that triggers the lint diagnostic without a suggestion.
46 lines
688 B
Rust
46 lines
688 B
Rust
#![warn(clippy::needless_bool)]
|
|
#![allow(
|
|
unused,
|
|
dead_code,
|
|
clippy::no_effect,
|
|
clippy::if_same_then_else,
|
|
clippy::needless_return
|
|
)]
|
|
|
|
fn main() {
|
|
let x = true;
|
|
let y = false;
|
|
if x {
|
|
true
|
|
} else {
|
|
true
|
|
};
|
|
if x {
|
|
false
|
|
} else {
|
|
false
|
|
};
|
|
if x {
|
|
x
|
|
} else {
|
|
false
|
|
}; // would also be questionable, but we don't catch this yet
|
|
bool_ret(x);
|
|
bool_ret2(x);
|
|
}
|
|
|
|
fn bool_ret(x: bool) -> bool {
|
|
if x {
|
|
return true;
|
|
} else {
|
|
return true;
|
|
};
|
|
}
|
|
|
|
fn bool_ret2(x: bool) -> bool {
|
|
if x {
|
|
return false;
|
|
} else {
|
|
return false;
|
|
};
|
|
}
|