Skip to content

Commit a34015c

Browse files
committed
implement and use diagnostic_snapshot
1 parent 527b1f3 commit a34015c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

+7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ impl<'a> Parser<'a> {
179179
&self.sess.span_diagnostic
180180
}
181181

182+
pub(super) fn diagnostic_snapshot(&self) -> Self {
183+
let mut snapshot = self.clone();
184+
// initialize unclosed_delims to avoid duplicate errors.
185+
snapshot.unclosed_delims = vec![];
186+
snapshot
187+
}
188+
182189
pub(super) fn span_to_snippet(&self, span: Span) -> Result<String, SpanSnippetError> {
183190
self.sess.source_map().span_to_snippet(span)
184191
}

compiler/rustc_parse/src/parser/path.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,7 @@ impl<'a> Parser<'a> {
625625
} else if self.check_type() {
626626
// Parse type argument.
627627
let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(token::Paren));
628-
let mut snapshot = self.clone();
629-
snapshot.unclosed_delims = vec![];
628+
let mut snapshot = self.diagnostic_snapshot();
630629
match self.parse_ty() {
631630
Ok(ty) => GenericArg::Type(ty),
632631
Err(err) => {

0 commit comments

Comments
 (0)