@@ -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 , PResult } ;
@@ -891,7 +891,8 @@ impl<'a> Parser<'a> {
891891 e. span_label ( path. span , "while parsing the fields for this pattern" ) ;
892892 e. emit ( ) ;
893893 self . recover_stmt ( ) ;
894- ( ThinVec :: new ( ) , true )
894+ // When recovering, pretend we had `Foo { .. }`, to avoid cascading errors.
895+ ( ThinVec :: new ( ) , PatFieldsRest :: Rest )
895896 } ) ;
896897 self . bump ( ) ;
897898 Ok ( PatKind :: Struct ( qself, path, fields, etc) )
@@ -965,9 +966,9 @@ impl<'a> Parser<'a> {
965966 }
966967
967968 /// Parses the fields of a struct-like pattern.
968- fn parse_pat_fields ( & mut self ) -> PResult < ' a , ( ThinVec < PatField > , bool ) > {
969+ fn parse_pat_fields ( & mut self ) -> PResult < ' a , ( ThinVec < PatField > , PatFieldsRest ) > {
969970 let mut fields = ThinVec :: new ( ) ;
970- let mut etc = false ;
971+ let mut etc = PatFieldsRest :: None ;
971972 let mut ate_comma = true ;
972973 let mut delayed_err: Option < DiagnosticBuilder < ' a > > = None ;
973974 let mut first_etc_and_maybe_comma_span = None ;
@@ -1001,7 +1002,7 @@ impl<'a> Parser<'a> {
10011002 || self . check_noexpect ( & token:: DotDotDot )
10021003 || self . check_keyword ( kw:: Underscore )
10031004 {
1004- etc = true ;
1005+ etc = PatFieldsRest :: Rest ;
10051006 let mut etc_sp = self . token . span ;
10061007 if first_etc_and_maybe_comma_span. is_none ( ) {
10071008 if let Some ( comma_tok) = self
0 commit comments