@@ -15,7 +15,7 @@ use rustc_ast::ptr::P;
1515use rustc_ast:: token:: { self , Delimiter } ;
1616use rustc_ast:: {
1717 self as ast, AttrVec , BindingAnnotation , ByRef , Expr , ExprKind , MacCall , Mutability , Pat ,
18- PatField , PatKind , Path , QSelf , RangeEnd , RangeSyntax ,
18+ PatField , PatFieldsRest , PatKind , Path , QSelf , RangeEnd , RangeSyntax ,
1919} ;
2020use rustc_ast_pretty:: pprust;
2121use rustc_errors:: { Applicability , DiagnosticBuilder , ErrorGuaranteed , IntoDiagnostic , PResult } ;
@@ -890,7 +890,8 @@ impl<'a> Parser<'a> {
890890 e. span_label ( path. span , "while parsing the fields for this pattern" ) ;
891891 e. emit ( ) ;
892892 self . recover_stmt ( ) ;
893- ( ThinVec :: new ( ) , true )
893+ // When recovering, pretend we had `Foo { .. }`, to avoid cascading errors.
894+ ( ThinVec :: new ( ) , PatFieldsRest :: Rest )
894895 } ) ;
895896 self . bump ( ) ;
896897 Ok ( PatKind :: Struct ( qself, path, fields, etc) )
@@ -964,9 +965,9 @@ impl<'a> Parser<'a> {
964965 }
965966
966967 /// Parses the fields of a struct-like pattern.
967- fn parse_pat_fields ( & mut self ) -> PResult < ' a , ( ThinVec < PatField > , bool ) > {
968+ fn parse_pat_fields ( & mut self ) -> PResult < ' a , ( ThinVec < PatField > , PatFieldsRest ) > {
968969 let mut fields = ThinVec :: new ( ) ;
969- let mut etc = false ;
970+ let mut etc = PatFieldsRest :: None ;
970971 let mut ate_comma = true ;
971972 let mut delayed_err: Option < DiagnosticBuilder < ' a , ErrorGuaranteed > > = None ;
972973 let mut first_etc_and_maybe_comma_span = None ;
@@ -1000,7 +1001,7 @@ impl<'a> Parser<'a> {
10001001 || self . check_noexpect ( & token:: DotDotDot )
10011002 || self . check_keyword ( kw:: Underscore )
10021003 {
1003- etc = true ;
1004+ etc = PatFieldsRest :: Rest ;
10041005 let mut etc_sp = self . token . span ;
10051006 if first_etc_and_maybe_comma_span. is_none ( ) {
10061007 if let Some ( comma_tok) = self
0 commit comments