Skip to content

Commit b56079e

Browse files
Add diagnostics test for mistyped inclusive ranges
1 parent fd406a8 commit b56079e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Makes sure that a helpful message is shown when someone mistypes
2+
// an inclusive range as `..==` rather than `..=`. This is an
3+
// easy mistake, because of the resemblance to`==`.
4+
// See #86395 for a bit of background.
5+
6+
pub fn main() {
7+
if let 1..==3 = 1 {} //~ERROR unexpected `=` after inclusive range
8+
//~|HELP use `..=` instead
9+
//~|NOTE inclusive ranges end with a single equals sign
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: unexpected `=` after inclusive range
2+
--> $DIR/range-inclusive-extra-equals.rs:7:13
3+
|
4+
LL | if let 1..==3 = 1 {}
5+
| ^^^^ help: use `..=` instead
6+
|
7+
= note: inclusive ranges end with a single equals sign (`..=`)
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)