]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_expr_like_matches_macro.rs
new lint: match_like_matches_macro
[rust.git] / tests / ui / match_expr_like_matches_macro.rs
1 // run-rustfix
2
3 #![warn(clippy::match_like_matches_macro)]
4
5 fn main() {
6     let x = Some(5);
7
8     // Lint
9     let _y = match x {
10         Some(0) => true,
11         _ => false,
12     };
13
14     // Turn into is_none
15     let _z = match x {
16         Some(_) => false,
17         None => true,
18     };
19
20     // Lint
21     let _z = match x {
22         Some(r) if r == 0 => false,
23         _ => true,
24     };
25
26     // Lint
27     let _zz = if let Some(5) = x { true } else { false };
28
29     // No lint
30     let _a = match x {
31         Some(_) => false,
32         None => false,
33     };
34
35     // No lint
36     let _a = match x {
37         Some(0) => false,
38         Some(_) => true,
39         None => false,
40     };
41 }