summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.fixed
blob: 3645f2c4bfdd2602ce3875322b49dc8924b9635f (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
69
70
71
72
73
74
75
76
// run-rustfix

#![warn(clippy::all)]
#![warn(clippy::redundant_pattern_matching)]
#![allow(
    unused_must_use,
    clippy::needless_bool,
    clippy::match_like_matches_macro,
    clippy::equatable_if_let,
    clippy::if_same_then_else
)]

use std::task::Poll::{self, Pending, Ready};

fn main() {
    if Pending::<()>.is_pending() {}

    if Ready(42).is_ready() {}

    if Ready(42).is_ready() {
        foo();
    } else {
        bar();
    }

    while Ready(42).is_ready() {}

    while Ready(42).is_pending() {}

    while Pending::<()>.is_pending() {}

    if Pending::<i32>.is_pending() {}

    if Ready(42).is_ready() {}

    Ready(42).is_ready();

    Pending::<()>.is_pending();

    let _ = Pending::<()>.is_pending();

    let poll = Ready(false);
    let _ = if poll.is_ready() { true } else { false };

    poll_const();

    let _ = if gen_poll().is_ready() {
        1
    } else if gen_poll().is_pending() {
        2
    } else {
        3
    };
}

fn gen_poll() -> Poll<()> {
    Pending
}

fn foo() {}

fn bar() {}

const fn poll_const() {
    if Ready(42).is_ready() {}

    if Pending::<()>.is_pending() {}

    while Ready(42).is_ready() {}

    while Pending::<()>.is_pending() {}

    Ready(42).is_ready();

    Pending::<()>.is_pending();
}