]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/redundant_pattern_matching_poll.fixed
New upstream version 1.53.0+dfsg1
[rustc.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::if_same_then_else
10 )]
11
12 use std::task::Poll::{self, Pending, Ready};
13
14 fn main() {
15 if Pending::<()>.is_pending() {}
16
17 if Ready(42).is_ready() {}
18
19 if Ready(42).is_ready() {
20 foo();
21 } else {
22 bar();
23 }
24
25 while Ready(42).is_ready() {}
26
27 while Ready(42).is_pending() {}
28
29 while Pending::<()>.is_pending() {}
30
31 if Pending::<i32>.is_pending() {}
32
33 if Ready(42).is_ready() {}
34
35 Ready(42).is_ready();
36
37 Pending::<()>.is_pending();
38
39 let _ = Pending::<()>.is_pending();
40
41 let poll = Ready(false);
42 let _ = if poll.is_ready() { true } else { false };
43
44 poll_const();
45
46 let _ = if gen_poll().is_ready() {
47 1
48 } else if gen_poll().is_pending() {
49 2
50 } else {
51 3
52 };
53 }
54
55 fn gen_poll() -> Poll<()> {
56 Pending
57 }
58
59 fn foo() {}
60
61 fn bar() {}
62
63 const fn poll_const() {
64 if Ready(42).is_ready() {}
65
66 if Pending::<()>.is_pending() {}
67
68 while Ready(42).is_ready() {}
69
70 while Pending::<()>.is_pending() {}
71
72 Ready(42).is_ready();
73
74 Pending::<()>.is_pending();
75 }