-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
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 ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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
I tried this code (reduced to minimal triggering case):
fn main() {
let (a, b, c) = (3, 4, 5);
let r: bool = match c {
_ => match a {
_ => true
} && match b {
_ => true,
},
};
}
Fails with the following error:
error: expected identifier, found keyword `match`
--> src/main.rs:7:14
|
7 | } && match b {
| ^^^^^ expected identifier, found keyword
error: expected one of `=>`, `@`, `if`, or `|`, found `b`
--> src/main.rs:7:20
|
7 | } && match b {
| ^ expected one of `=>`, `@`, `if`, or `|`
error: aborting due to 2 previous errors
However, the following works as expected:
fn main() {
let (a, b, c) = (3, 4, 5);
let r: bool = match a {
_ => true,
} && match b {
_ => true,
};
}
Given that the second example compiles, we should expect the first one to compile as well.
Meta
I've found this issues on all rust versions 1.54.0 to 1.57 nightly inclusive. It doesn't look like a regression, since the same code is rejected as far back as 1.30, just with a different error message.
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 ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.