From b86a1d1c07fcf9049bbe3f61c369932d5d8b169a Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Wed, 23 Mar 2022 01:26:34 +0900 Subject: [PATCH] replace `this.clone()` with `this.create_snapshot_for_diagnostic()` --- compiler/rustc_parse/src/parser/generics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index 1b9eeab029862..d625080dee4fd 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -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( @@ -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)); } }