From 84a13a28b749eb4765da0918131a47461fb99e3d Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sun, 12 Jun 2022 17:27:36 +0900 Subject: [PATCH] use `create_snapshot_for_diagnostic` instead of `clone` --- compiler/rustc_expand/src/mbe/macro_rules.rs | 2 +- compiler/rustc_parse/src/parser/diagnostics.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index b86304ba6b1..8cb938f40af 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -123,7 +123,7 @@ pub(crate) fn make(mut self: Box>, kind: AstFragmentKind) -> is_trailing_mac, is_local, } = *self; - let snapshot = &mut parser.clone(); + let snapshot = &mut parser.create_snapshot_for_diagnostic(); let fragment = match parse_ast_fragment(parser, kind) { Ok(f) => f, Err(err) => { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index a4cdfdf55f9..6a44f5d6653 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -336,7 +336,7 @@ struct InInTypo { // SnapshotParser is used to create a snapshot of the parser // without causing duplicate errors being emitted when the `Parser` // is dropped. -pub(super) struct SnapshotParser<'a> { +pub struct SnapshotParser<'a> { parser: Parser<'a>, unclosed_delims: Vec, } @@ -392,7 +392,7 @@ pub fn unclosed_delims(&self) -> &[UnmatchedBrace] { } /// 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 unclosed_delims = self.unclosed_delims.clone(); // Clear `unclosed_delims` in snapshot to avoid