use create_snapshot_for_diagnostic instead of clone for Parser

This commit is contained in:
Takayuki Maeda 2022-08-15 16:42:58 +09:00
parent 0068b8bf4b
commit 84f0d5e460

View File

@ -2260,7 +2260,7 @@ fn parse_param_general(&mut self, req_name: ReqName, first_param: bool) -> PResu
(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()
@ -2283,7 +2283,7 @@ fn parse_param_general(&mut self, req_name: ReqName, first_param: bool) -> PResu
// 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()?
}
}