@@ -15,7 +15,7 @@ use rustc_ast::ptr::P;
15
15
use rustc_ast:: token:: { self , Delimiter } ;
16
16
use rustc_ast:: {
17
17
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 ,
19
19
} ;
20
20
use rustc_ast_pretty:: pprust;
21
21
use rustc_errors:: { Applicability , DiagnosticBuilder , PResult } ;
@@ -891,7 +891,8 @@ impl<'a> Parser<'a> {
891
891
e. span_label ( path. span , "while parsing the fields for this pattern" ) ;
892
892
e. emit ( ) ;
893
893
self . recover_stmt ( ) ;
894
- ( ThinVec :: new ( ) , true )
894
+ // When recovering, pretend we had `Foo { .. }`, to avoid cascading errors.
895
+ ( ThinVec :: new ( ) , PatFieldsRest :: Rest )
895
896
} ) ;
896
897
self . bump ( ) ;
897
898
Ok ( PatKind :: Struct ( qself, path, fields, etc) )
@@ -965,9 +966,9 @@ impl<'a> Parser<'a> {
965
966
}
966
967
967
968
/// 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 ) > {
969
970
let mut fields = ThinVec :: new ( ) ;
970
- let mut etc = false ;
971
+ let mut etc = PatFieldsRest :: None ;
971
972
let mut ate_comma = true ;
972
973
let mut delayed_err: Option < DiagnosticBuilder < ' a > > = None ;
973
974
let mut first_etc_and_maybe_comma_span = None ;
@@ -1001,7 +1002,7 @@ impl<'a> Parser<'a> {
1001
1002
|| self . check_noexpect ( & token:: DotDotDot )
1002
1003
|| self . check_keyword ( kw:: Underscore )
1003
1004
{
1004
- etc = true ;
1005
+ etc = PatFieldsRest :: Rest ;
1005
1006
let mut etc_sp = self . token . span ;
1006
1007
if first_etc_and_maybe_comma_span. is_none ( ) {
1007
1008
if let Some ( comma_tok) = self
0 commit comments