Skip to content

Commit

Permalink
Rollup merge of #95212 - TaKO8Ki:replace-this-clone-with-this-create-…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Dylan-DPC committed Mar 23, 2022
2 parents 25acd93 + b86a1d1 commit 0254928
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a> Parser<'a> {
Some(this.parse_ty_param(attrs)?)
} else if this.token.can_begin_type() {
// Trying to write an associated type bound? (#26271)
let snapshot = this.clone();
let snapshot = this.create_snapshot_for_diagnostic();
match this.parse_ty_where_predicate() {
Ok(where_predicate) => {
this.struct_span_err(
Expand All @@ -133,7 +133,7 @@ impl<'a> Parser<'a> {
Err(err) => {
err.cancel();
// FIXME - maybe we should overwrite 'self' outside of `collect_tokens`?
*this = snapshot;
this.restore_snapshot(snapshot);
return Ok((None, TrailingToken::None));
}
}
Expand Down

0 comments on commit 0254928

Please sign in to comment.