Closed
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
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.`#![feature(or_patterns)]`Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.