Skip to content

Commit 06ca6bb

Browse files
committed
Add tests
1 parent b776d1c commit 06ca6bb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/test/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ fn main() {
3333
m!(0u8, 25, 20..=30);
3434
m!(0u8, 30, 20..=30); //~ ERROR multiple patterns covering the same range
3535

36+
match 0u8 {
37+
0..=10 => {}
38+
20..=30 => {}
39+
10..=20 => {} //~ ERROR multiple patterns covering the same range
40+
_ => {}
41+
}
3642
match (0u8, true) {
3743
(0..=10, true) => {}
3844
(10..20, true) => {} // not detected

src/test/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr

+13-3
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,30 @@ LL | m!(0u8, 30, 20..=30);
6161
| this range overlaps on `30_u8`
6262

6363
error: multiple patterns covering the same range
64-
--> $DIR/overlapping_range_endpoints.rs:44:16
64+
--> $DIR/overlapping_range_endpoints.rs:39:9
65+
|
66+
LL | 0..=10 => {}
67+
| ------ this range overlaps on `10_u8`
68+
LL | 20..=30 => {}
69+
| ------- this range overlaps on `20_u8`
70+
LL | 10..=20 => {}
71+
| ^^^^^^^ overlapping patterns
72+
73+
error: multiple patterns covering the same range
74+
--> $DIR/overlapping_range_endpoints.rs:50:16
6575
|
6676
LL | (true, 0..=10) => {}
6777
| ------ this range overlaps on `10_u8`
6878
LL | (true, 10..20) => {}
6979
| ^^^^^^ overlapping patterns
7080

7181
error: multiple patterns covering the same range
72-
--> $DIR/overlapping_range_endpoints.rs:50:14
82+
--> $DIR/overlapping_range_endpoints.rs:56:14
7383
|
7484
LL | Some(0..=10) => {}
7585
| ------ this range overlaps on `10_u8`
7686
LL | Some(10..20) => {}
7787
| ^^^^^^ overlapping patterns
7888

79-
error: aborting due to 9 previous errors
89+
error: aborting due to 10 previous errors
8090

0 commit comments

Comments
 (0)