about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-02 19:29:27 +0000
committerbors <bors@rust-lang.org>2020-09-02 19:29:27 +0000
commit80fc9b0ecb29050d45b17c64af004200afd3cfc2 (patch)
tree3d0269d8f9ecb027bd59a942462003ed9e01e4ea /compiler/rustc_parse/src/parser
parenta167485e279be8a11c9c09d0dddaf1d7c5724f1c (diff)
parent3524c3ef4371d0bf4dd03568a004039f18c154f7 (diff)
downloadrust-80fc9b0ecb29050d45b17c64af004200afd3cfc2.tar.gz
rust-80fc9b0ecb29050d45b17c64af004200afd3cfc2.zip
Auto merge of #76160 - scileo:format-recovery, r=petrochenkov
Improve recovery on malformed format call

The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues.

r? @petrochenkov
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index d90a61cd34a..84edfecad19 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -1234,6 +1234,10 @@ impl<'a> Parser<'a> {
                 *t == token::OpenDelim(token::Brace) || *t == token::BinOp(token::Star)
             })
     }
+
+    pub fn clear_expected_tokens(&mut self) {
+        self.expected_tokens.clear();
+    }
 }
 
 crate fn make_unclosed_delims_error(