about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorsjwang05 <63834813+sjwang05@users.noreply.github.com>2023-11-10 12:13:53 -0800
committersjwang05 <63834813+sjwang05@users.noreply.github.com>2023-11-10 12:13:53 -0800
commita49368f00b66409ae9fcf42d52e4f8246c73c266 (patch)
treef8beed04dd8913947502276fa91bbf726fd8ac64 /compiler/rustc_parse/src
parent9455259450f0186df991a14d960bb3759e7eac43 (diff)
downloadrust-a49368f00b66409ae9fcf42d52e4f8246c73c266.tar.gz
rust-a49368f00b66409ae9fcf42d52e4f8246c73c266.zip
Correctly handle while-let-chains
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/lexer/tokentrees.rs2
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs
index e7d2c678824..41f4d0055aa 100644
--- a/compiler/rustc_parse/src/lexer/tokentrees.rs
+++ b/compiler/rustc_parse/src/lexer/tokentrees.rs
@@ -129,7 +129,7 @@ impl<'a> TokenTreesReader<'a> {
             while parser.token != token::Eof {
                 if let Err(diff_err) = parser.err_diff_marker() {
                     diff_errs.push(diff_err);
-                } else if parser.token.is_keyword(kw::If) {
+                } else if parser.is_keyword_ahead(0, &[kw::If, kw::While]) {
                     in_cond = true;
                 } else if matches!(
                     parser.token.kind,
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 1a7ae406911..6eab140117e 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -1115,7 +1115,7 @@ impl<'a> Parser<'a> {
     }
 
     /// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
-    fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool {
+    pub fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool {
         self.look_ahead(dist, |t| kws.iter().any(|&kw| t.is_keyword(kw)))
     }