Improve diagnostic for missing space in range pattern

This commit is contained in:
clubby789 2023-01-30 23:47:10 +00:00
parent a9985cf172
commit 4ab75de934
6 changed files with 24 additions and 21 deletions

View file

@ -2,7 +2,8 @@ fn main() {
let x = 42;
match x {
0..=73 => {},
74..=> {}, //~ ERROR unexpected `=>` after open range
//~^ ERROR expected one of `=>`, `if`, or `|`, found `>`
74..=> {},
//~^ ERROR unexpected `>` after inclusive range
//~| NOTE this is parsed as an inclusive range `..=`
}
}

View file

@ -1,19 +1,15 @@
error: unexpected `=>` after open range
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:11
error: unexpected `>` after inclusive range
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
|
LL | 74..=> {},
| ^^^
| ---^
| |
| this is parsed as an inclusive range `..=`
|
help: add a space between the pattern and `=>`
|
LL | 74.. => {},
| +
error: expected one of `=>`, `if`, or `|`, found `>`
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
|
LL | 74..=> {},
| ^ expected one of `=>`, `if`, or `|`
error: aborting due to 2 previous errors
error: aborting due to previous error