]> git.lizzy.rs Git - rust.git/blob - tests/ui/redundant_pattern_matching_drop_order.fixed
Improve `redundant_pattern_matching`
[rust.git] / tests / ui / redundant_pattern_matching_drop_order.fixed
1 // run-rustfix
2
3 // Issue #5746
4 #![warn(clippy::redundant_pattern_matching)]
5 #![allow(clippy::if_same_then_else)]
6 use std::task::Poll::{Pending, Ready};
7
8 fn main() {
9     let m = std::sync::Mutex::new((0, 0));
10
11     // Result
12     if m.lock().is_ok() {}
13     if Err::<(), _>(m.lock().unwrap().0).is_err() {}
14
15     {
16         if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {}
17     }
18     if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {
19     } else {
20     }
21     if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {}
22     if Err::<std::sync::MutexGuard<()>, _>(()).is_err() {}
23
24     if Ok::<_, ()>(String::new()).is_ok() {}
25     if Err::<(), _>((String::new(), ())).is_err() {}
26
27     // Option
28     if Some(m.lock()).is_some() {}
29     if Some(m.lock().unwrap().0).is_some() {}
30
31     {
32         if None::<std::sync::MutexGuard<()>>.is_none() {}
33     }
34     if None::<std::sync::MutexGuard<()>>.is_none() {
35     } else {
36     }
37
38     if None::<std::sync::MutexGuard<()>>.is_none() {}
39
40     if Some(String::new()).is_some() {}
41     if Some((String::new(), ())).is_some() {}
42
43     // Poll
44     if Ready(m.lock()).is_ready() {}
45     if Ready(m.lock().unwrap().0).is_ready() {}
46
47     {
48         if Pending::<std::sync::MutexGuard<()>>.is_pending() {}
49     }
50     if Pending::<std::sync::MutexGuard<()>>.is_pending() {
51     } else {
52     }
53
54     if Pending::<std::sync::MutexGuard<()>>.is_pending() {}
55
56     if Ready(String::new()).is_ready() {}
57     if Ready((String::new(), ())).is_ready() {}
58 }