Skip to content

Commit 84a13a2

Browse files
committed
use create_snapshot_for_diagnostic instead of clone
1 parent 7092d42 commit 84a13a2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a> ParserAnyMacro<'a> {
123123
is_trailing_mac,
124124
is_local,
125125
} = *self;
126-
let snapshot = &mut parser.clone();
126+
let snapshot = &mut parser.create_snapshot_for_diagnostic();
127127
let fragment = match parse_ast_fragment(parser, kind) {
128128
Ok(f) => f,
129129
Err(err) => {

compiler/rustc_parse/src/parser/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct InInTypo {
336336
// SnapshotParser is used to create a snapshot of the parser
337337
// without causing duplicate errors being emitted when the `Parser`
338338
// is dropped.
339-
pub(super) struct SnapshotParser<'a> {
339+
pub struct SnapshotParser<'a> {
340340
parser: Parser<'a>,
341341
unclosed_delims: Vec<UnmatchedBrace>,
342342
}
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
392392
}
393393

394394
/// Create a snapshot of the `Parser`.
395-
pub(super) fn create_snapshot_for_diagnostic(&self) -> SnapshotParser<'a> {
395+
pub fn create_snapshot_for_diagnostic(&self) -> SnapshotParser<'a> {
396396
let mut snapshot = self.clone();
397397
let unclosed_delims = self.unclosed_delims.clone();
398398
// Clear `unclosed_delims` in snapshot to avoid

0 commit comments

Comments
 (0)