Rollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebank

Improve diagnostic for missing space in range pattern

Improves the diagnostic in #107425 by turning it into a note explaining the parsing issue.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2023-02-02 17:14:05 +01:00 committed by GitHub
commit e9c4e291c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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