Auto merge of #98020 - TaKO8Ki:use-create-snapshot-for-diagnostic-in-rustc-expand, r=Dylan-DPC
Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`
Use [`create_snapshot_for_diagnostic`](cd11905716/compiler/rustc_parse/src/parser/diagnostics.rs (L214-L223)
) I implemented in https://github.com/rust-lang/rust/pull/94731 instead of `clone` to avoid duplicate unclosed delims errors being emitted when the `Parser` is dropped. I missed this one in #95068.
This commit is contained in:
commit
1fb9603022
@ -123,7 +123,7 @@ pub(crate) fn make(mut self: Box<ParserAnyMacro<'a>>, 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) => {
|
||||
|
@ -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<UnmatchedBrace>,
|
||||
}
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user