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