implement and use diagnostic_snapshot
This commit is contained in:
parent
527b1f3c2f
commit
a34015c0d0
2 changed files with 8 additions and 2 deletions
|
@ -179,6 +179,13 @@ impl<'a> Parser<'a> {
|
||||||
&self.sess.span_diagnostic
|
&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> {
|
pub(super) fn span_to_snippet(&self, span: Span) -> Result<String, SpanSnippetError> {
|
||||||
self.sess.source_map().span_to_snippet(span)
|
self.sess.source_map().span_to_snippet(span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,8 +625,7 @@ impl<'a> Parser<'a> {
|
||||||
} else if self.check_type() {
|
} else if self.check_type() {
|
||||||
// Parse type argument.
|
// Parse type argument.
|
||||||
let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(token::Paren));
|
let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(token::Paren));
|
||||||
let mut snapshot = self.clone();
|
let mut snapshot = self.diagnostic_snapshot();
|
||||||
snapshot.unclosed_delims = vec![];
|
|
||||||
match self.parse_ty() {
|
match self.parse_ty() {
|
||||||
Ok(ty) => GenericArg::Type(ty),
|
Ok(ty) => GenericArg::Type(ty),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue