Skip to content

Commit 0254928

Browse files
authored
Rollup merge of #95212 - TaKO8Ki:replace-this-clone-with-this-create-snapshot-for-diagnostic, r=Dylan-DPC
Replace `this.clone()` with `this.create_snapshot_for_diagnostic()` Use [`create_snapshot_for_diagnostic`](https://github.com/rust-lang/rust/blob/cd119057160cedea245aa2679add56723f3dc784/compiler/rustc_parse/src/parser/diagnostics.rs#L214-L223) I implemented in #94731 instead of `this.clone()` to avoid duplicate errors about unclosed delims being emitted when the `Parser` is dropped.
2 parents 25acd93 + b86a1d1 commit 0254928

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_parse/src/parser/generics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a> Parser<'a> {
118118
Some(this.parse_ty_param(attrs)?)
119119
} else if this.token.can_begin_type() {
120120
// Trying to write an associated type bound? (#26271)
121-
let snapshot = this.clone();
121+
let snapshot = this.create_snapshot_for_diagnostic();
122122
match this.parse_ty_where_predicate() {
123123
Ok(where_predicate) => {
124124
this.struct_span_err(
@@ -133,7 +133,7 @@ impl<'a> Parser<'a> {
133133
Err(err) => {
134134
err.cancel();
135135
// FIXME - maybe we should overwrite 'self' outside of `collect_tokens`?
136-
*this = snapshot;
136+
this.restore_snapshot(snapshot);
137137
return Ok((None, TrailingToken::None));
138138
}
139139
}

0 commit comments

Comments
 (0)