1
+ use super :: diagnostics:: SnapshotParser ;
1
2
use super :: pat:: { CommaRecoveryMode , RecoverColon , RecoverComma , PARAM_EXPECTED } ;
2
3
use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
3
4
use super :: {
4
- AttrWrapper , BlockMode , ClosureSpans , ForceCollect , Parser , PathStyle , Restrictions , TokenType ,
5
+ AttrWrapper , BlockMode , ClosureSpans , ForceCollect , Parser , PathStyle , Restrictions ,
6
+ SemiColonMode , SeqSep , TokenExpectType , TokenType , TrailingToken ,
5
7
} ;
6
- use super :: { SemiColonMode , SeqSep , TokenExpectType , TrailingToken } ;
7
8
use crate :: maybe_recover_from_interpolated_ty_qpath;
8
9
9
10
use ast:: token:: DelimToken ;
@@ -1105,7 +1106,7 @@ impl<'a> Parser<'a> {
1105
1106
let snapshot = if self . token . kind == token:: OpenDelim ( token:: Paren )
1106
1107
&& self . look_ahead_type_ascription_as_field ( )
1107
1108
{
1108
- Some ( ( self . clone ( ) , fun. kind . clone ( ) ) )
1109
+ Some ( ( self . create_snapshot_for_diagnostic ( ) , fun. kind . clone ( ) ) )
1109
1110
} else {
1110
1111
None
1111
1112
} ;
@@ -1130,7 +1131,7 @@ impl<'a> Parser<'a> {
1130
1131
lo : Span ,
1131
1132
open_paren : Span ,
1132
1133
seq : & mut PResult < ' a , P < Expr > > ,
1133
- snapshot : Option < ( Self , ExprKind ) > ,
1134
+ snapshot : Option < ( SnapshotParser < ' a > , ExprKind ) > ,
1134
1135
) -> Option < P < Expr > > {
1135
1136
match ( seq. as_mut ( ) , snapshot) {
1136
1137
( Err ( err) , Some ( ( mut snapshot, ExprKind :: Path ( None , path) ) ) ) => {
@@ -1140,7 +1141,7 @@ impl<'a> Parser<'a> {
1140
1141
Ok ( ( fields, ..) ) if snapshot. eat ( & token:: CloseDelim ( token:: Paren ) ) => {
1141
1142
// We are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
1142
1143
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
1143
- * self = snapshot;
1144
+ self . restore_snapshot ( snapshot) ;
1144
1145
let close_paren = self . prev_token . span ;
1145
1146
let span = lo. to ( self . prev_token . span ) ;
1146
1147
if !fields. is_empty ( ) {
0 commit comments