Closed
Description
The compiler could suggest that e
identifier must precede the pattern in the following code:
playpen link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ca2dc7094a56b0478edefe0faefefe0e
fn main() {
let x = 2;
match x {
1 ..= 5 @ e => {}
_ => {}
}
}
Current error message:
error: expected one of `=>`, `if`, or `|`, found `@`
--> src/main.rs:5:17
|
5 | 1 ..= 5 @ e => {}
| ^ expected one of `=>`, `if`, or `|` here
error: aborting due to previous error
It could be improved as:
error: expected one of `=>`, `if`, or `|`, found `@`
--> src/main.rs:5:17
|
5 | 1 ..= 5 @ e => {}
| ^ expected one of `=>`, `if`, or `|` here
| help: try `e @ 1 ..= 5`
error: aborting due to previous error