Do not lint when range is completely included into another one

This commit is contained in:
ThibsG 2021-01-15 18:51:00 +01:00
parent 583715f583
commit 70704db36f
3 changed files with 24 additions and 26 deletions

View file

@ -57,6 +57,18 @@ fn overlapping() {
_ => (),
}
match 42 {
5..7 => println!("5 .. 7"),
0..10 => println!("0 .. 10"),
_ => (),
}
match 42 {
5..10 => println!("5 .. 10"),
0..=10 => println!("0 ... 10"),
_ => (),
}
/*
// FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns
match 42 {

View file

@ -23,30 +23,6 @@ note: overlaps with this
LL | FOO..=11 => println!("0 ... 11"),
| ^^^^^^^^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:26:9
|
LL | 0..=5 => println!("0 ... 5"),
| ^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:25:9
|
LL | 2 => println!("2"),
| ^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:32:9
|
LL | 0..=2 => println!("0 ... 2"),
| ^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:31:9
|
LL | 2 => println!("2"),
| ^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:55:9
|
@ -59,5 +35,5 @@ note: overlaps with this
LL | 0..=11 => println!("0 ... 11"),
| ^^^^^^
error: aborting due to 5 previous errors
error: aborting due to 3 previous errors