]> git.lizzy.rs Git - rust.git/blob - tests/ui/redundant_pattern_matching.rs
Merge branch 'master' into rustfmt_tests
[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 #![warn(clippy::all)]
11 #![warn(clippy::redundant_pattern_matching)]
12
13 fn main() {
14     if let Ok(_) = Ok::<i32, i32>(42) {}
15
16     if let Err(_) = Err::<i32, i32>(42) {}
17
18     if let None = None::<()> {}
19
20     if let Some(_) = Some(42) {}
21
22     if Ok::<i32, i32>(42).is_ok() {}
23
24     if Err::<i32, i32>(42).is_err() {}
25
26     if None::<i32>.is_none() {}
27
28     if Some(42).is_some() {}
29
30     if let Ok(x) = Ok::<i32, i32>(42) {
31         println!("{}", x);
32     }
33
34     match Ok::<i32, i32>(42) {
35         Ok(_) => true,
36         Err(_) => false,
37     };
38
39     match Ok::<i32, i32>(42) {
40         Ok(_) => false,
41         Err(_) => true,
42     };
43
44     match Err::<i32, i32>(42) {
45         Ok(_) => false,
46         Err(_) => true,
47     };
48
49     match Err::<i32, i32>(42) {
50         Ok(_) => true,
51         Err(_) => false,
52     };
53
54     match Some(42) {
55         Some(_) => true,
56         None => false,
57     };
58
59     match None::<()> {
60         Some(_) => false,
61         None => true,
62     };
63 }