]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwco
[rust.git] / src / test / ui / pattern / usefulness / integer-ranges / overlapping_range_endpoints.rs
1 #![feature(exclusive_range_pattern)]
2 #![deny(overlapping_range_endpoints)]
3
4 macro_rules! m {
5     ($s:expr, $t1:pat, $t2:pat) => {
6         match $s {
7             $t1 => {}
8             $t2 => {}
9             _ => {}
10         }
11     }
12 }
13
14 fn main() {
15     m!(0u8, 20..=30, 30..=40); //~ ERROR multiple patterns overlap on their endpoints
16     m!(0u8, 30..=40, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
17     m!(0u8, 20..=30, 31..=40);
18     m!(0u8, 20..=30, 29..=40);
19     m!(0u8, 20.. 30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
20     m!(0u8, 20.. 30, 28..=40);
21     m!(0u8, 20.. 30, 30..=40);
22     m!(0u8, 20..=30, 30..=30);
23     m!(0u8, 20..=30, 30..=31); //~ ERROR multiple patterns overlap on their endpoints
24     m!(0u8, 20..=30, 29..=30);
25     m!(0u8, 20..=30, 20..=20);
26     m!(0u8, 20..=30, 20..=21);
27     m!(0u8, 20..=30, 19..=20); //~ ERROR multiple patterns overlap on their endpoints
28     m!(0u8, 20..=30, 20);
29     m!(0u8, 20..=30, 25);
30     m!(0u8, 20..=30, 30);
31     m!(0u8, 20.. 30, 29);
32     m!(0u8, 20, 20..=30);
33     m!(0u8, 25, 20..=30);
34     m!(0u8, 30, 20..=30);
35
36     match 0u8 {
37         0..=10 => {}
38         20..=30 => {}
39         10..=20 => {} //~ ERROR multiple patterns overlap on their endpoints
40         _ => {}
41     }
42     match (0u8, true) {
43         (0..=10, true) => {}
44         (10..20, true) => {} // not detected
45         (10..20, false) => {}
46         _ => {}
47     }
48     match (true, 0u8) {
49         (true, 0..=10) => {}
50         (true, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
51         (false, 10..20) => {}
52         _ => {}
53     }
54     match Some(0u8) {
55         Some(0..=10) => {}
56         Some(10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
57         _ => {}
58     }
59 }