@@ -6829,14 +6829,16 @@ impl<'a> Parser<'a> {
6829
6829
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
6830
6830
} else {
6831
6831
// If we see: `struct Foo<T> where T: Copy { ... }`
6832
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6832
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6833
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6833
6834
}
6834
6835
// No `where` so: `struct Foo<T>;`
6835
6836
} else if self . eat ( & token:: Semi ) {
6836
6837
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
6837
6838
// Record-style struct definition
6838
6839
} else if self . token == token:: OpenDelim ( token:: Brace ) {
6839
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6840
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6841
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6840
6842
// Tuple-style struct definition with optional where-clause.
6841
6843
} else if self . token == token:: OpenDelim ( token:: Paren ) {
6842
6844
let body = VariantData :: Tuple ( self . parse_tuple_struct_body ( ) ?, ast:: DUMMY_NODE_ID ) ;
@@ -6864,9 +6866,11 @@ impl<'a> Parser<'a> {
6864
6866
6865
6867
let vdata = if self . token . is_keyword ( keywords:: Where ) {
6866
6868
generics. where_clause = self . parse_where_clause ( ) ?;
6867
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6869
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6870
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6868
6871
} else if self . token == token:: OpenDelim ( token:: Brace ) {
6869
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6872
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6873
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6870
6874
} else {
6871
6875
let token_str = self . this_token_descr ( ) ;
6872
6876
let mut err = self . fatal ( & format ! (
@@ -6898,12 +6902,14 @@ impl<'a> Parser<'a> {
6898
6902
}
6899
6903
}
6900
6904
6901
- fn parse_record_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
6905
+ fn parse_record_struct_body ( & mut self ) -> PResult < ' a , ( Vec < StructField > , bool ) > {
6902
6906
let mut fields = Vec :: new ( ) ;
6907
+ let mut recovered = false ;
6903
6908
if self . eat ( & token:: OpenDelim ( token:: Brace ) ) {
6904
6909
while self . token != token:: CloseDelim ( token:: Brace ) {
6905
6910
let field = self . parse_struct_decl_field ( ) . map_err ( |e| {
6906
6911
self . recover_stmt ( ) ;
6912
+ recovered = true ;
6907
6913
e
6908
6914
} ) ;
6909
6915
match field {
@@ -6922,7 +6928,7 @@ impl<'a> Parser<'a> {
6922
6928
return Err ( err) ;
6923
6929
}
6924
6930
6925
- Ok ( fields)
6931
+ Ok ( ( fields, recovered ) )
6926
6932
}
6927
6933
6928
6934
fn parse_tuple_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
@@ -7684,12 +7690,14 @@ impl<'a> Parser<'a> {
7684
7690
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
7685
7691
// Parse a struct variant.
7686
7692
all_nullary = false ;
7687
- struct_def = VariantData :: Struct ( self . parse_record_struct_body ( ) ?,
7688
- ast:: DUMMY_NODE_ID ) ;
7693
+ let ( fields , recovered ) = self . parse_record_struct_body ( ) ?;
7694
+ struct_def = VariantData :: Struct ( fields , ast:: DUMMY_NODE_ID , recovered ) ;
7689
7695
} else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
7690
7696
all_nullary = false ;
7691
- struct_def = VariantData :: Tuple ( self . parse_tuple_struct_body ( ) ?,
7692
- ast:: DUMMY_NODE_ID ) ;
7697
+ struct_def = VariantData :: Tuple (
7698
+ self . parse_tuple_struct_body ( ) ?,
7699
+ ast:: DUMMY_NODE_ID ,
7700
+ ) ;
7693
7701
} else if self . eat ( & token:: Eq ) {
7694
7702
disr_expr = Some ( AnonConst {
7695
7703
id : ast:: DUMMY_NODE_ID ,
0 commit comments