]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_overlapping_arm.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / match_overlapping_arm.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 #![feature(exclusive_range_pattern)]
11 #![warn(clippy::match_overlapping_arm)]
12 #![allow(clippy::redundant_pattern_matching)]
13
14 /// Tests for match_overlapping_arm
15
16 fn overlapping() {
17     const FOO: u64 = 2;
18
19     match 42 {
20         0...10 => println!("0 ... 10"),
21         0...11 => println!("0 ... 11"),
22         _ => (),
23     }
24
25     match 42 {
26         0...5 => println!("0 ... 5"),
27         6...7 => println!("6 ... 7"),
28         FOO...11 => println!("0 ... 11"),
29         _ => (),
30     }
31
32     match 42 {
33         2 => println!("2"),
34         0...5 => println!("0 ... 5"),
35         _ => (),
36     }
37
38     match 42 {
39         2 => println!("2"),
40         0...2 => println!("0 ... 2"),
41         _ => (),
42     }
43
44     match 42 {
45         0...10 => println!("0 ... 10"),
46         11...50 => println!("11 ... 50"),
47         _ => (),
48     }
49
50     match 42 {
51         2 => println!("2"),
52         0..2 => println!("0 .. 2"),
53         _ => (),
54     }
55
56     match 42 {
57         0..10 => println!("0 .. 10"),
58         10..50 => println!("10 .. 50"),
59         _ => (),
60     }
61
62     match 42 {
63         0..11 => println!("0 .. 11"),
64         0...11 => println!("0 ... 11"),
65         _ => (),
66     }
67
68     if let None = Some(42) {
69         // nothing
70     } else if let None = Some(42) {
71         // another nothing :-)
72     }
73 }
74
75 fn main() {}