@@ -6837,14 +6837,16 @@ impl<'a> Parser<'a> {
6837
6837
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
6838
6838
} else {
6839
6839
// If we see: `struct Foo<T> where T: Copy { ... }`
6840
- 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)
6841
6842
}
6842
6843
// No `where` so: `struct Foo<T>;`
6843
6844
} else if self . eat ( & token:: Semi ) {
6844
6845
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
6845
6846
// Record-style struct definition
6846
6847
} else if self . token == token:: OpenDelim ( token:: Brace ) {
6847
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6848
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6849
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6848
6850
// Tuple-style struct definition with optional where-clause.
6849
6851
} else if self . token == token:: OpenDelim ( token:: Paren ) {
6850
6852
let body = VariantData :: Tuple ( self . parse_tuple_struct_body ( ) ?, ast:: DUMMY_NODE_ID ) ;
@@ -6872,9 +6874,11 @@ impl<'a> Parser<'a> {
6872
6874
6873
6875
let vdata = if self . token . is_keyword ( keywords:: Where ) {
6874
6876
generics. where_clause = self . parse_where_clause ( ) ?;
6875
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6877
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6878
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6876
6879
} else if self . token == token:: OpenDelim ( token:: Brace ) {
6877
- VariantData :: Struct ( self . parse_record_struct_body ( ) ?, ast:: DUMMY_NODE_ID )
6880
+ let ( fields, recovered) = self . parse_record_struct_body ( ) ?;
6881
+ VariantData :: Struct ( fields, ast:: DUMMY_NODE_ID , recovered)
6878
6882
} else {
6879
6883
let token_str = self . this_token_descr ( ) ;
6880
6884
let mut err = self . fatal ( & format ! (
@@ -6906,12 +6910,16 @@ impl<'a> Parser<'a> {
6906
6910
}
6907
6911
}
6908
6912
6909
- fn parse_record_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
6913
+ fn parse_record_struct_body (
6914
+ & mut self ,
6915
+ ) -> PResult < ' a , ( Vec < StructField > , /* recovered */ bool ) > {
6910
6916
let mut fields = Vec :: new ( ) ;
6917
+ let mut recovered = false ;
6911
6918
if self . eat ( & token:: OpenDelim ( token:: Brace ) ) {
6912
6919
while self . token != token:: CloseDelim ( token:: Brace ) {
6913
6920
let field = self . parse_struct_decl_field ( ) . map_err ( |e| {
6914
6921
self . recover_stmt ( ) ;
6922
+ recovered = true ;
6915
6923
e
6916
6924
} ) ;
6917
6925
match field {
@@ -6930,7 +6938,7 @@ impl<'a> Parser<'a> {
6930
6938
return Err ( err) ;
6931
6939
}
6932
6940
6933
- Ok ( fields)
6941
+ Ok ( ( fields, recovered ) )
6934
6942
}
6935
6943
6936
6944
fn parse_tuple_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
@@ -7692,12 +7700,14 @@ impl<'a> Parser<'a> {
7692
7700
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
7693
7701
// Parse a struct variant.
7694
7702
all_nullary = false ;
7695
- struct_def = VariantData :: Struct ( self . parse_record_struct_body ( ) ?,
7696
- ast:: DUMMY_NODE_ID ) ;
7703
+ let ( fields , recovered ) = self . parse_record_struct_body ( ) ?;
7704
+ struct_def = VariantData :: Struct ( fields , ast:: DUMMY_NODE_ID , recovered ) ;
7697
7705
} else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
7698
7706
all_nullary = false ;
7699
- struct_def = VariantData :: Tuple ( self . parse_tuple_struct_body ( ) ?,
7700
- ast:: DUMMY_NODE_ID ) ;
7707
+ struct_def = VariantData :: Tuple (
7708
+ self . parse_tuple_struct_body ( ) ?,
7709
+ ast:: DUMMY_NODE_ID ,
7710
+ ) ;
7701
7711
} else if self . eat ( & token:: Eq ) {
7702
7712
disr_expr = Some ( AnonConst {
7703
7713
id : ast:: DUMMY_NODE_ID ,
0 commit comments