summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/redundant_pattern_matching_drop_order.fixed
blob: ce3229f17591e472251795bd1cd24646ead95a5b (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
// run-rustfix

// Issue #5746
#![warn(clippy::redundant_pattern_matching)]
#![allow(clippy::if_same_then_else, clippy::equatable_if_let)]
use std::task::Poll::{Pending, Ready};

fn main() {
    let m = std::sync::Mutex::new((0, 0));

    // Result
    if m.lock().is_ok() {}
    if Err::<(), _>(m.lock().unwrap().0).is_err() {}

    {
        if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {}
    }
    if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {
    } else {
    }
    if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {}
    if Err::<std::sync::MutexGuard<()>, _>(()).is_err() {}

    if Ok::<_, ()>(String::new()).is_ok() {}
    if Err::<(), _>((String::new(), ())).is_err() {}

    // Option
    if Some(m.lock()).is_some() {}
    if Some(m.lock().unwrap().0).is_some() {}

    {
        if None::<std::sync::MutexGuard<()>>.is_none() {}
    }
    if None::<std::sync::MutexGuard<()>>.is_none() {
    } else {
    }

    if None::<std::sync::MutexGuard<()>>.is_none() {}

    if Some(String::new()).is_some() {}
    if Some((String::new(), ())).is_some() {}

    // Poll
    if Ready(m.lock()).is_ready() {}
    if Ready(m.lock().unwrap().0).is_ready() {}

    {
        if Pending::<std::sync::MutexGuard<()>>.is_pending() {}
    }
    if Pending::<std::sync::MutexGuard<()>>.is_pending() {
    } else {
    }

    if Pending::<std::sync::MutexGuard<()>>.is_pending() {}

    if Ready(String::new()).is_ready() {}
    if Ready((String::new(), ())).is_ready() {}
}