@@ -4769,43 +4769,32 @@ impl<'a> Parser<'a> {
4769
4769
generics : & mut ast:: Generics )
4770
4770
-> PResult < Vec < StructField > > {
4771
4771
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
4772
- if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
4773
- let fields = try!( self . parse_unspanned_seq (
4774
- & token:: OpenDelim ( token:: Paren ) ,
4775
- & token:: CloseDelim ( token:: Paren ) ,
4776
- seq_sep_trailing_allowed ( token:: Comma ) ,
4777
- |p| {
4778
- let attrs = p. parse_outer_attributes ( ) ;
4779
- let lo = p. span . lo ;
4780
- let struct_field_ = ast:: StructField_ {
4781
- kind : UnnamedField ( try!( p. parse_visibility ( ) ) ) ,
4782
- id : ast:: DUMMY_NODE_ID ,
4783
- ty : try!( p. parse_ty_sum ( ) ) ,
4784
- attrs : attrs,
4785
- } ;
4786
- Ok ( spanned ( lo, p. span . hi , struct_field_) )
4787
- } ) ) ;
4788
-
4789
- if fields. is_empty ( ) {
4790
- return Err ( self . fatal ( & format ! ( "unit-like struct definition should be \
4791
- written as `struct {};`",
4792
- class_name) ) ) ;
4793
- }
4772
+ // Unit like structs are handled in parse_item_struct function
4773
+ let fields = try!( self . parse_unspanned_seq (
4774
+ & token:: OpenDelim ( token:: Paren ) ,
4775
+ & token:: CloseDelim ( token:: Paren ) ,
4776
+ seq_sep_trailing_allowed ( token:: Comma ) ,
4777
+ |p| {
4778
+ let attrs = p. parse_outer_attributes ( ) ;
4779
+ let lo = p. span . lo ;
4780
+ let struct_field_ = ast:: StructField_ {
4781
+ kind : UnnamedField ( try!( p. parse_visibility ( ) ) ) ,
4782
+ id : ast:: DUMMY_NODE_ID ,
4783
+ ty : try!( p. parse_ty_sum ( ) ) ,
4784
+ attrs : attrs,
4785
+ } ;
4786
+ Ok ( spanned ( lo, p. span . hi , struct_field_) )
4787
+ } ) ) ;
4794
4788
4795
- generics. where_clause = try!( self . parse_where_clause ( ) ) ;
4796
- try!( self . expect ( & token:: Semi ) ) ;
4797
- Ok ( fields)
4798
- // This is the case where we just see struct Foo<T> where T: Copy;
4799
- } else if self . token . is_keyword ( keywords:: Where ) {
4800
- generics. where_clause = try!( self . parse_where_clause ( ) ) ;
4801
- try!( self . expect ( & token:: Semi ) ) ;
4802
- Ok ( Vec :: new ( ) )
4803
- // This case is where we see: `struct Foo<T>;`
4804
- } else {
4805
- let token_str = self . this_token_to_string ( ) ;
4806
- Err ( self . fatal ( & format ! ( "expected `where`, `{}`, `(`, or `;` after struct \
4807
- name, found `{}`", "{" , token_str) ) )
4789
+ if fields. is_empty ( ) {
4790
+ return Err ( self . fatal ( & format ! ( "unit-like struct definition should be \
4791
+ written as `struct {};`",
4792
+ class_name) ) ) ;
4808
4793
}
4794
+
4795
+ generics. where_clause = try!( self . parse_where_clause ( ) ) ;
4796
+ try!( self . expect ( & token:: Semi ) ) ;
4797
+ Ok ( fields)
4809
4798
}
4810
4799
4811
4800
/// Parse a structure field declaration
0 commit comments