]> git.lizzy.rs Git - rust.git/blob - tests/ui/redundant_pattern_matching.rs
Rename if_let_redundant_pattern_matching to redundant_pattern_matching
[rust.git] / tests / ui / redundant_pattern_matching.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11
12
13
14 #![warn(clippy::all)]
15 #![warn(clippy::redundant_pattern_matching)]
16
17
18 fn main() {
19     if let Ok(_) = Ok::<i32, i32>(42) {}
20
21     if let Err(_) = Err::<i32, i32>(42) {
22     }
23
24     if let None = None::<()> {
25     }
26
27     if let Some(_) = Some(42) {
28     }
29
30     if Ok::<i32, i32>(42).is_ok() {
31     }
32
33     if Err::<i32, i32>(42).is_err() {
34     }
35
36     if None::<i32>.is_none() {
37     }
38
39     if Some(42).is_some() {
40     }
41
42     if let Ok(x) = Ok::<i32,i32>(42) {
43         println!("{}", x);
44     }
45
46     match Ok::<i32, i32>(42) {
47         Ok(_) => true,
48         Err(_) => false,
49     };
50
51     match Ok::<i32, i32>(42) {
52         Ok(_) => false,
53         Err(_) => true,
54     };
55
56     match Err::<i32, i32>(42) {
57         Ok(_) => false,
58         Err(_) => true,
59     };
60
61     match Err::<i32, i32>(42) {
62         Ok(_) => true,
63         Err(_) => false,
64     };
65
66     match Some(42) {
67         Some(_) => true,
68         None => false,
69     };
70
71     match None::<()> {
72         Some(_) => false,
73         None => true,
74     };
75 }