-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.