about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-15 10:28:14 +0200
committerGitHub <noreply@github.com>2022-08-15 10:28:14 +0200
commitfece51174be4fbd89a08cdbcad4533b856795cae (patch)
tree264e65c1c6626b490078835fb77fc11dffebede3
parent748925bf1bbb63dc3a8cab3d661b9a9192593fb5 (diff)
parent84f0d5e460786d071ff3598637c24137ef866509 (diff)
downloadrust-fece51174be4fbd89a08cdbcad4533b856795cae.tar.gz
rust-fece51174be4fbd89a08cdbcad4533b856795cae.zip
Rollup merge of #100566 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=cjgillot
Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`

follow-up to #98020
-rw-r--r--compiler/rustc_parse/src/parser/item.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 83fab0829a1..81d0e4733d0 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -2309,7 +2309,7 @@ impl<'a> Parser<'a> {
                 (pat, this.parse_ty_for_param()?)
             } else {
                 debug!("parse_param_general ident_to_pat");
-                let parser_snapshot_before_ty = this.clone();
+                let parser_snapshot_before_ty = this.create_snapshot_for_diagnostic();
                 this.eat_incorrect_doc_comment_for_param_type();
                 let mut ty = this.parse_ty_for_param();
                 if ty.is_ok()
@@ -2332,7 +2332,7 @@ impl<'a> Parser<'a> {
                     // Recover from attempting to parse the argument as a type without pattern.
                     Err(err) => {
                         err.cancel();
-                        *this = parser_snapshot_before_ty;
+                        this.restore_snapshot(parser_snapshot_before_ty);
                         this.recover_arg_parse()?
                     }
                 }