2018-10-30 20:36:52 +00:00
|
|
|
#![warn(clippy::match_overlapping_arm)]
|
|
|
|
#![allow(clippy::redundant_pattern_matching)]
|
2023-07-02 12:35:19 +00:00
|
|
|
#![allow(clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_if)]
|
2018-10-30 20:36:52 +00:00
|
|
|
|
|
|
|
fn overlapping() {
|
2018-12-09 22:26:16 +00:00
|
|
|
const FOO: u64 = 2;
|
2018-10-30 20:36:52 +00:00
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=10 => println!("0..=10"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=11 => println!("0..=11"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=5 => println!("0..=5"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-10-21 11:11:36 +00:00
|
|
|
6..=7 => println!("6..=7"),
|
|
|
|
FOO..=11 => println!("FOO..=11"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=5 => println!("0..=5"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=2 => println!("0..=2"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=10 => println!("0..=10"),
|
|
|
|
11..=50 => println!("11..=50"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
|
|
|
2 => println!("2"),
|
2021-10-21 11:11:36 +00:00
|
|
|
0..2 => println!("0..2"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..10 => println!("0..10"),
|
|
|
|
10..50 => println!("10..50"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..11 => println!("0..11"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=11 => println!("0..=11"),
|
2018-10-30 20:36:52 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-02-03 04:43:30 +00:00
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
5..7 => println!("5..7"),
|
|
|
|
0..10 => println!("0..10"),
|
2021-02-03 04:43:30 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
5..10 => println!("5..10"),
|
|
|
|
0..=10 => println!("0..=10"),
|
2021-02-03 04:43:30 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..14 => println!("0..14"),
|
|
|
|
5..10 => println!("5..10"),
|
2021-02-03 04:43:30 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
5..14 => println!("5..14"),
|
|
|
|
0..=10 => println!("0..=10"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-02-03 04:43:30 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
0..7 => println!("0..7"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-10-21 11:11:36 +00:00
|
|
|
0..=10 => println!("0..=10"),
|
2021-02-03 04:43:30 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2020-01-11 10:39:43 +00:00
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
3.. => println!("3.."),
|
|
|
|
0.. => println!("0.."),
|
2020-01-11 10:39:43 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
match 42 {
|
2021-10-21 11:11:36 +00:00
|
|
|
..=23 => println!("..=23"),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-10-21 11:11:36 +00:00
|
|
|
..26 => println!("..26"),
|
2020-01-11 10:39:43 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-12-06 11:33:31 +00:00
|
|
|
// Issue #7816 - overlap after included range
|
|
|
|
match 42 {
|
|
|
|
5..=10 => (),
|
|
|
|
0..=20 => (),
|
|
|
|
21..=30 => (),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-12-06 11:33:31 +00:00
|
|
|
21..=40 => (),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-11-04 12:52:36 +00:00
|
|
|
// Issue #7829
|
|
|
|
match 0 {
|
|
|
|
-1..=1 => (),
|
|
|
|
-2..=2 => (),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2021-12-06 11:33:31 +00:00
|
|
|
// Only warn about the first if there are multiple overlaps
|
|
|
|
match 42u128 {
|
|
|
|
0..=0x0000_0000_0000_00ff => (),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: some ranges overlap
|
2021-12-06 11:33:31 +00:00
|
|
|
0..=0x0000_0000_0000_ffff => (),
|
|
|
|
0..=0x0000_0000_ffff_ffff => (),
|
|
|
|
0..=0xffff_ffff_ffff_ffff => (),
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2018-10-30 20:36:52 +00:00
|
|
|
if let None = Some(42) {
|
|
|
|
// nothing
|
|
|
|
} else if let None = Some(42) {
|
|
|
|
// another nothing :-)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|