Open
Description
I think I found a case where I am hitting an issue with Rust's parser which seems to get confused on the following bit of code:
fn main() {
let x = 2;
let y = 1;
let test = match x {
2 => match y {
1 => true,
_ => false,
} && true,
_ => false,
};
}
I expected that it would compile similar to the snippet below:
fn main() {
let x = 2;
let y = 1;
let test = match x {
2 => {
let foo = match y {
1 => true,
_ => false,
};
foo && true
}
_ => false,
};
}
Instead, it seems to hit a parsing issue following the &&
after the inner match
yielding a bool
, where it shows the following error instead:
error: unexpected , in pattern
--> src/main.rs:11:18
|
11 | } && true,
| ^
|
help: try adding parentheses to match on a tuple...
|
11 ~ } (&& true,
12 ~ _) => false,
|
help: ...or a vertical bar to match on multiple alternatives
|
11 ~ } && true |
12 ~ _ => false,
This happens on:
$ rustc --version
rustc 1.65.0 (897e37553 2022-11-02)
As well as on:
$ rustc +nightly --version
rustc 1.67.0-nightly (73c9eaf21 2022-11-07)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.