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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#![warn(clippy::redundant_pattern_matching)]
#![allow(
clippy::needless_bool,
clippy::needless_if,
clippy::match_like_matches_macro,
clippy::equatable_if_let,
clippy::if_same_then_else
)]
use std::task::Poll::{self, Pending, Ready};
fn main() {
if let Pending = Pending::<()> {}
//~^ redundant_pattern_matching
if let Ready(_) = Ready(42) {}
//~^ redundant_pattern_matching
if let Ready(_) = Ready(42) {
//~^ redundant_pattern_matching
foo();
} else {
bar();
}
// Issue 6459
if matches!(Ready(42), Ready(_)) {}
//~^ redundant_pattern_matching
// Issue 6459
if matches!(Pending::<()>, Pending) {}
//~^ redundant_pattern_matching
while let Ready(_) = Ready(42) {}
//~^ redundant_pattern_matching
while let Pending = Ready(42) {}
//~^ redundant_pattern_matching
while let Pending = Pending::<()> {}
//~^ redundant_pattern_matching
if Pending::<i32>.is_pending() {}
if Ready(42).is_ready() {}
match Ready(42) {
//~^ redundant_pattern_matching
Ready(_) => true,
Pending => false,
};
match Pending::<()> {
//~^ redundant_pattern_matching
Ready(_) => false,
Pending => true,
};
let _ = match Pending::<()> {
//~^ redundant_pattern_matching
Ready(_) => false,
Pending => true,
};
let poll = Ready(false);
let _ = if let Ready(_) = poll { true } else { false };
//~^ redundant_pattern_matching
poll_const();
let _ = if let Ready(_) = gen_poll() {
//~^ redundant_pattern_matching
1
} else if let Pending = gen_poll() {
//~^ redundant_pattern_matching
2
} else {
3
};
}
fn gen_poll() -> Poll<()> {
Pending
}
fn foo() {}
fn bar() {}
const fn poll_const() {
if let Ready(_) = Ready(42) {}
//~^ redundant_pattern_matching
if let Pending = Pending::<()> {}
//~^ redundant_pattern_matching
while let Ready(_) = Ready(42) {}
//~^ redundant_pattern_matching
while let Pending = Pending::<()> {}
//~^ redundant_pattern_matching
match Ready(42) {
//~^ redundant_pattern_matching
Ready(_) => true,
Pending => false,
};
match Pending::<()> {
//~^ redundant_pattern_matching
Ready(_) => false,
Pending => true,
};
}
|