about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs7
-rw-r--r--compiler/rustc_parse/src/parser/path.rs3
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 40daf4eb28f..94805f4eb8b 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -179,6 +179,13 @@ impl<'a> Parser<'a> {
         &self.sess.span_diagnostic
     }
 
+    pub(super) fn diagnostic_snapshot(&self) -> Self {
+        let mut snapshot = self.clone();
+        // initialize unclosed_delims to avoid duplicate errors.
+        snapshot.unclosed_delims = vec![];
+        snapshot
+    }
+
     pub(super) fn span_to_snippet(&self, span: Span) -> Result<String, SpanSnippetError> {
         self.sess.source_map().span_to_snippet(span)
     }
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 750d7cce0c0..f300b9c5ae4 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -625,8 +625,7 @@ impl<'a> Parser<'a> {
         } else if self.check_type() {
             // Parse type argument.
             let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(token::Paren));
-            let mut snapshot = self.clone();
-            snapshot.unclosed_delims = vec![];
+            let mut snapshot = self.diagnostic_snapshot();
             match self.parse_ty() {
                 Ok(ty) => GenericArg::Type(ty),
                 Err(err) => {