about summary refs log tree commit diff
path: root/compiler/rustc_parse
diff options
context:
space:
mode:
authorsjwang05 <63834813+sjwang05@users.noreply.github.com>2023-11-09 20:04:55 -0800
committersjwang05 <63834813+sjwang05@users.noreply.github.com>2023-11-09 20:07:17 -0800
commit9455259450f0186df991a14d960bb3759e7eac43 (patch)
treee53c5c704067575d82245ce0b6ea6677507659c3 /compiler/rustc_parse
parent00942381575bc6c081835dbb38f68ce9603c032f (diff)
downloadrust-9455259450f0186df991a14d960bb3759e7eac43.tar.gz
rust-9455259450f0186df991a14d960bb3759e7eac43.zip
Catch an edge case
Diffstat (limited to 'compiler/rustc_parse')
-rw-r--r--compiler/rustc_parse/src/lexer/tokentrees.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs
index 7aa4ac7c4cb..e7d2c678824 100644
--- a/compiler/rustc_parse/src/lexer/tokentrees.rs
+++ b/compiler/rustc_parse/src/lexer/tokentrees.rs
@@ -131,7 +131,11 @@ impl<'a> TokenTreesReader<'a> {
                     diff_errs.push(diff_err);
                 } else if parser.token.is_keyword(kw::If) {
                     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;
                 } else if in_cond && parser.token == token::OpenDelim(Delimiter::Brace) {
                     // Store the `&&` and `let` to use their spans later when creating the diagnostic