blob: ad08c21ba9edea87b20f858778e4c08898eeb1ef (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//@revisions: edition2021 edition2024
//@[edition2021] edition:2021
//@[edition2024] edition:2024
//@[edition2021] check-pass
#![warn(clippy::collapsible_if)]
fn main() {
if let Some(a) = Some(3) {
// with comment, so do not lint
if let Some(b) = Some(4) {
let _ = a + b;
}
}
//~[edition2024]v collapsible_if
if let Some(a) = Some(3)
&& let Some(b) = Some(4) {
let _ = a + b;
}
//~[edition2024]v collapsible_if
if let Some(a) = Some(3)
&& a + 1 == 4 {
let _ = a;
}
//~[edition2024]v collapsible_if
if Some(3) == Some(4).map(|x| x - 1)
&& let Some(b) = Some(4) {
let _ = b;
}
fn truth() -> bool {
true
}
// Prefix:
//~[edition2024]v collapsible_if
if let 0 = 1
&& truth() {}
// Suffix:
//~[edition2024]v collapsible_if
if truth()
&& let 0 = 1 {}
// Midfix:
//~[edition2024]vvv collapsible_if
//~[edition2024]v collapsible_if
if truth()
&& let 0 = 1
&& truth() {}
}
#[clippy::msrv = "1.87.0"]
fn msrv_1_87() {
if let 0 = 1 {
if true {}
}
}
#[clippy::msrv = "1.88.0"]
fn msrv_1_88() {
//~[edition2024]v collapsible_if
if let 0 = 1
&& true {}
}
|