Skip to content

Commit 0518911

Browse files
committed
Add more tests for match_overlapping_arm lint
1 parent 70704db commit 0518911

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

tests/ui/match_overlapping_arm.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ fn overlapping() {
6969
_ => (),
7070
}
7171

72+
match 42 {
73+
0..14 => println!("0 .. 14"),
74+
5..10 => println!("5 .. 10"),
75+
_ => (),
76+
}
77+
78+
match 42 {
79+
5..14 => println!("5 .. 14"),
80+
0..=10 => println!("0 ... 10"),
81+
_ => (),
82+
}
83+
84+
match 42 {
85+
0..7 => println!("0 .. 7"),
86+
0..=10 => println!("0 ... 10"),
87+
_ => (),
88+
}
89+
7290
/*
7391
// FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns
7492
match 42 {

tests/ui/match_overlapping_arm.stderr

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,29 @@ note: overlaps with this
3535
LL | 0..=11 => println!("0 ... 11"),
3636
| ^^^^^^
3737

38-
error: aborting due to 3 previous errors
38+
error: some ranges overlap
39+
--> $DIR/match_overlapping_arm.rs:80:9
40+
|
41+
LL | 0..=10 => println!("0 ... 10"),
42+
| ^^^^^^
43+
|
44+
note: overlaps with this
45+
--> $DIR/match_overlapping_arm.rs:79:9
46+
|
47+
LL | 5..14 => println!("5 .. 14"),
48+
| ^^^^^
49+
50+
error: some ranges overlap
51+
--> $DIR/match_overlapping_arm.rs:85:9
52+
|
53+
LL | 0..7 => println!("0 .. 7"),
54+
| ^^^^
55+
|
56+
note: overlaps with this
57+
--> $DIR/match_overlapping_arm.rs:86:9
58+
|
59+
LL | 0..=10 => println!("0 ... 10"),
60+
| ^^^^^^
61+
62+
error: aborting due to 5 previous errors
3963

0 commit comments

Comments
 (0)