2020-11-20 13:03:56 -06:00
|
|
|
#![feature(exclusive_range_pattern)]
|
2020-10-22 12:34:00 -05:00
|
|
|
#![deny(overlapping_range_endpoints)]
|
2020-11-20 13:03:56 -06:00
|
|
|
|
|
|
|
macro_rules! m {
|
|
|
|
($s:expr, $t1:pat, $t2:pat) => {
|
|
|
|
match $s {
|
|
|
|
$t1 => {}
|
|
|
|
$t2 => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
2023-10-21 11:08:09 -05:00
|
|
|
};
|
2020-11-20 13:03:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2020-10-22 12:34:00 -05:00
|
|
|
m!(0u8, 20..=30, 30..=40); //~ ERROR multiple patterns overlap on their endpoints
|
|
|
|
m!(0u8, 30..=40, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
m!(0u8, 20..=30, 31..=40);
|
|
|
|
m!(0u8, 20..=30, 29..=40);
|
2023-10-21 11:08:09 -05:00
|
|
|
m!(0u8, 20..30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
|
|
|
|
m!(0u8, 20..30, 28..=40);
|
|
|
|
m!(0u8, 20..30, 30..=40);
|
2020-11-20 13:03:56 -06:00
|
|
|
m!(0u8, 20..=30, 30..=30);
|
2020-10-22 12:34:00 -05:00
|
|
|
m!(0u8, 20..=30, 30..=31); //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
m!(0u8, 20..=30, 29..=30);
|
|
|
|
m!(0u8, 20..=30, 20..=20);
|
|
|
|
m!(0u8, 20..=30, 20..=21);
|
2020-10-22 12:34:00 -05:00
|
|
|
m!(0u8, 20..=30, 19..=20); //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
m!(0u8, 20..=30, 20);
|
|
|
|
m!(0u8, 20..=30, 25);
|
|
|
|
m!(0u8, 20..=30, 30);
|
2023-10-21 11:08:09 -05:00
|
|
|
m!(0u8, 20..30, 29);
|
2020-10-22 13:25:55 -05:00
|
|
|
m!(0u8, 20, 20..=30);
|
2020-11-20 13:03:56 -06:00
|
|
|
m!(0u8, 25, 20..=30);
|
2020-10-22 13:25:55 -05:00
|
|
|
m!(0u8, 30, 20..=30);
|
2020-11-20 13:03:56 -06:00
|
|
|
|
2020-11-22 15:58:41 -06:00
|
|
|
match 0u8 {
|
|
|
|
0..=10 => {}
|
|
|
|
20..=30 => {}
|
2023-10-21 11:08:09 -05:00
|
|
|
10..=20 => {}
|
|
|
|
//~^ ERROR multiple patterns overlap on their endpoints
|
|
|
|
//~| ERROR multiple patterns overlap on their endpoints
|
2020-11-22 15:58:41 -06:00
|
|
|
_ => {}
|
|
|
|
}
|
2020-11-20 13:03:56 -06:00
|
|
|
match (0u8, true) {
|
|
|
|
(0..=10, true) => {}
|
2023-10-21 11:08:09 -05:00
|
|
|
(10..20, true) => {} //~ ERROR multiple patterns overlap on their endpoints
|
|
|
|
(10..20, false) => {} //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
match (true, 0u8) {
|
|
|
|
(true, 0..=10) => {}
|
2020-10-22 12:34:00 -05:00
|
|
|
(true, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
|
2023-10-21 11:08:09 -05:00
|
|
|
(false, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
match Some(0u8) {
|
|
|
|
Some(0..=10) => {}
|
2020-10-22 12:34:00 -05:00
|
|
|
Some(10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
|
2020-11-20 13:03:56 -06:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|