]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/redundant_pattern_matching_poll.fixed
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
[rust.git] / src / tools / clippy / tests / ui / redundant_pattern_matching_poll.fixed
1 // run-rustfix
2
3 #![warn(clippy::all)]
4 #![warn(clippy::redundant_pattern_matching)]
5 #![allow(
6     unused_must_use,
7     clippy::needless_bool,
8     clippy::match_like_matches_macro,
9     clippy::equatable_if_let,
10     clippy::if_same_then_else
11 )]
12
13 use std::task::Poll::{self, Pending, Ready};
14
15 fn main() {
16     if Pending::<()>.is_pending() {}
17
18     if Ready(42).is_ready() {}
19
20     if Ready(42).is_ready() {
21         foo();
22     } else {
23         bar();
24     }
25
26     while Ready(42).is_ready() {}
27
28     while Ready(42).is_pending() {}
29
30     while Pending::<()>.is_pending() {}
31
32     if Pending::<i32>.is_pending() {}
33
34     if Ready(42).is_ready() {}
35
36     Ready(42).is_ready();
37
38     Pending::<()>.is_pending();
39
40     let _ = Pending::<()>.is_pending();
41
42     let poll = Ready(false);
43     let _ = if poll.is_ready() { true } else { false };
44
45     poll_const();
46
47     let _ = if gen_poll().is_ready() {
48         1
49     } else if gen_poll().is_pending() {
50         2
51     } else {
52         3
53     };
54 }
55
56 fn gen_poll() -> Poll<()> {
57     Pending
58 }
59
60 fn foo() {}
61
62 fn bar() {}
63
64 const fn poll_const() {
65     if Ready(42).is_ready() {}
66
67     if Pending::<()>.is_pending() {}
68
69     while Ready(42).is_ready() {}
70
71     while Pending::<()>.is_pending() {}
72
73     Ready(42).is_ready();
74
75     Pending::<()>.is_pending();
76 }