Add diagnostics test for mistyped inclusive ranges

This commit is contained in:
inquisitivecrystal 2021-07-11 16:51:56 -07:00
parent fd406a8865
commit b56079ec54
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,10 @@
// Makes sure that a helpful message is shown when someone mistypes
// an inclusive range as `..==` rather than `..=`. This is an
// easy mistake, because of the resemblance to`==`.
// See #86395 for a bit of background.
pub fn main() {
if let 1..==3 = 1 {} //~ERROR unexpected `=` after inclusive range
//~|HELP use `..=` instead
//~|NOTE inclusive ranges end with a single equals sign
}

View file

@ -0,0 +1,10 @@
error: unexpected `=` after inclusive range
--> $DIR/range-inclusive-extra-equals.rs:7:13
|
LL | if let 1..==3 = 1 {}
| ^^^^ help: use `..=` instead
|
= note: inclusive ranges end with a single equals sign (`..=`)
error: aborting due to previous error