Catch an edge case

This commit is contained in:
sjwang05 2023-11-09 20:04:55 -08:00
parent 0094238157
commit 9455259450
No known key found for this signature in database
GPG Key ID: AB262FD6FFBFCFFE
3 changed files with 18 additions and 2 deletions

View File

@ -131,7 +131,11 @@ fn parse_token_tree_open_delim(
diff_errs.push(diff_err); diff_errs.push(diff_err);
} else if parser.token.is_keyword(kw::If) { } else if parser.token.is_keyword(kw::If) {
in_cond = true; in_cond = true;
} else if parser.token == token::CloseDelim(Delimiter::Brace) { } else if matches!(
parser.token.kind,
token::CloseDelim(Delimiter::Brace) | token::FatArrow
) {
// end of the `if`/`while` body, or the end of a `match` guard
in_cond = false; in_cond = false;
} else if in_cond && parser.token == token::OpenDelim(Delimiter::Brace) { } else if in_cond && parser.token == token::OpenDelim(Delimiter::Brace) {
// Store the `&&` and `let` to use their spans later when creating the diagnostic // Store the `&&` and `let` to use their spans later when creating the diagnostic

View File

@ -9,6 +9,15 @@ fn main() {
} }
} }
fn qux() {
let foo = false;
match foo {
_ if foo => {
&& let () = ()
_ => {}
}
}
fn foo() { fn foo() {
{ {
&& let () = () && let () = ()

View File

@ -1,9 +1,12 @@
error: this file contains an unclosed delimiter error: this file contains an unclosed delimiter
--> $DIR/brace-in-let-chain.rs:28:54 --> $DIR/brace-in-let-chain.rs:37:54
| |
LL | fn main() { LL | fn main() {
| - unclosed delimiter | - unclosed delimiter
... ...
LL | fn qux() {
| - unclosed delimiter
...
LL | fn foo() { LL | fn foo() {
| - unclosed delimiter | - unclosed delimiter
... ...