1
Fork 0

implement and use diagnostic_snapshot

This commit is contained in:
Takayuki Maeda 2022-03-09 13:48:40 +09:00
parent 527b1f3c2f
commit a34015c0d0
2 changed files with 8 additions and 2 deletions

View file

@ -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)
}