1+ use super :: diagnostics:: SnapshotParser ;
12use super :: pat:: { CommaRecoveryMode , RecoverColon , RecoverComma , PARAM_EXPECTED } ;
23use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
34use super :: {
4- AttrWrapper , BlockMode , ClosureSpans , ForceCollect , Parser , PathStyle , Restrictions , TokenType ,
5+ AttrWrapper , BlockMode , ClosureSpans , ForceCollect , Parser , PathStyle , Restrictions ,
6+ SemiColonMode , SeqSep , TokenExpectType , TokenType , TrailingToken ,
57} ;
6- use super :: { SemiColonMode , SeqSep , TokenExpectType , TrailingToken } ;
78use crate :: maybe_recover_from_interpolated_ty_qpath;
89
910use ast:: token:: DelimToken ;
@@ -1105,7 +1106,7 @@ impl<'a> Parser<'a> {
11051106 let snapshot = if self . token . kind == token:: OpenDelim ( token:: Paren )
11061107 && self . look_ahead_type_ascription_as_field ( )
11071108 {
1108- Some ( ( self . clone ( ) , fun. kind . clone ( ) ) )
1109+ Some ( ( self . create_snapshot_for_diagnostic ( ) , fun. kind . clone ( ) ) )
11091110 } else {
11101111 None
11111112 } ;
@@ -1130,7 +1131,7 @@ impl<'a> Parser<'a> {
11301131 lo : Span ,
11311132 open_paren : Span ,
11321133 seq : & mut PResult < ' a , P < Expr > > ,
1133- snapshot : Option < ( Self , ExprKind ) > ,
1134+ snapshot : Option < ( SnapshotParser < ' a > , ExprKind ) > ,
11341135 ) -> Option < P < Expr > > {
11351136 match ( seq. as_mut ( ) , snapshot) {
11361137 ( Err ( err) , Some ( ( mut snapshot, ExprKind :: Path ( None , path) ) ) ) => {
@@ -1140,7 +1141,7 @@ impl<'a> Parser<'a> {
11401141 Ok ( ( fields, ..) ) if snapshot. eat ( & token:: CloseDelim ( token:: Paren ) ) => {
11411142 // We are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
11421143 // `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
1143- * self = snapshot;
1144+ self . restore_snapshot ( snapshot) ;
11441145 let close_paren = self . prev_token . span ;
11451146 let span = lo. to ( self . prev_token . span ) ;
11461147 if !fields. is_empty ( ) {
0 commit comments