use `create_snapshot_for_diagnostic` instead of `clone`

This commit is contained in:
Takayuki Maeda 2022-06-12 17:27:36 +09:00
parent 7092d42c04
commit 84a13a28b7
2 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,7 @@ impl<'a> ParserAnyMacro<'a> {
is_trailing_mac, is_trailing_mac,
is_local, is_local,
} = *self; } = *self;
let snapshot = &mut parser.clone(); let snapshot = &mut parser.create_snapshot_for_diagnostic();
let fragment = match parse_ast_fragment(parser, kind) { let fragment = match parse_ast_fragment(parser, kind) {
Ok(f) => f, Ok(f) => f,
Err(err) => { Err(err) => {

View File

@ -336,7 +336,7 @@ struct InInTypo {
// SnapshotParser is used to create a snapshot of the parser // SnapshotParser is used to create a snapshot of the parser
// without causing duplicate errors being emitted when the `Parser` // without causing duplicate errors being emitted when the `Parser`
// is dropped. // is dropped.
pub(super) struct SnapshotParser<'a> { pub struct SnapshotParser<'a> {
parser: Parser<'a>, parser: Parser<'a>,
unclosed_delims: Vec<UnmatchedBrace>, unclosed_delims: Vec<UnmatchedBrace>,
} }
@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
} }
/// Create a snapshot of the `Parser`. /// Create a snapshot of the `Parser`.
pub(super) fn create_snapshot_for_diagnostic(&self) -> SnapshotParser<'a> { pub fn create_snapshot_for_diagnostic(&self) -> SnapshotParser<'a> {
let mut snapshot = self.clone(); let mut snapshot = self.clone();
let unclosed_delims = self.unclosed_delims.clone(); let unclosed_delims = self.unclosed_delims.clone();
// Clear `unclosed_delims` in snapshot to avoid // Clear `unclosed_delims` in snapshot to avoid