-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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 ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-or_patterns`#![feature(or_patterns)]``#![feature(or_patterns)]`P-lowLow priorityLow priorityT-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
Detect and recover the following incorrect code:
enum E {
A,
B,
}
fn main() {
match E::A {
E::A |
E::B | // This pipe or operand shouldn't be here
if true => {}
_ => {}
}
}
which currently emits
error: expected identifier, found keyword `if`
--> src/main.rs:10:9
|
10 | if true => {}
| ^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
10 | r#if true => {}
| ^^^^
error: expected one of `=>`, `@`, `if`, or `|`, found `true`
--> src/main.rs:10:12
|
10 | if true => {}
| ^^^^ expected one of `=>`, `@`, `if`, or `|` here
The parser should instead detect it is parsing a match arm guard.
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 ASTA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-or_patterns`#![feature(or_patterns)]``#![feature(or_patterns)]`P-lowLow priorityLow priorityT-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.