blob: 3ed31d4d711fac4b0ce60d5e583cb3fa7b2553d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//@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 };
a.field = random() && random();
a.field = !(random() && random());
// 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.
random(); a.field = true;
let mut b = false;
if random() {
a.field = false;
} else {
b = true;
}
}
|