mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-24 03:53:20 +00:00
46 lines
843 B
Rust
46 lines
843 B
Rust
|
//@run-rustfix
|
||
|
|
||
|
#![allow(unused)]
|
||
|
#![warn(clippy::needless_bool_assign)]
|
||
|
|
||
|
fn random() -> bool {
|
||
|
true
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
struct Data {
|
||
|
field: bool,
|
||
|
};
|
||
|
let mut a = Data { field: false };
|
||
|
if random() && random() {
|
||
|
a.field = true;
|
||
|
} else {
|
||
|
a.field = false
|
||
|
}
|
||
|
if random() && random() {
|
||
|
a.field = false;
|
||
|
} else {
|
||
|
a.field = true
|
||
|
}
|
||
|
// Do not lint…
|
||
|
if random() {
|
||
|
a.field = false;
|
||
|
} else {
|
||
|
// …to avoid losing this comment
|
||
|
a.field = true
|
||
|
}
|
||
|
// This one also triggers lint `clippy::if_same_then_else`
|
||
|
// which does not suggest a rewrite.
|
||
|
if random() {
|
||
|
a.field = true;
|
||
|
} else {
|
||
|
a.field = true;
|
||
|
}
|
||
|
let mut b = false;
|
||
|
if random() {
|
||
|
a.field = false;
|
||
|
} else {
|
||
|
b = true;
|
||
|
}
|
||
|
}
|