@@ -99,13 +99,6 @@ pub enum BoundParsingMode {
99
99
Modified ,
100
100
}
101
101
102
- /// `pub` should be parsed in struct fields and not parsed in variant fields
103
- #[ derive( Clone , Copy , PartialEq ) ]
104
- pub enum ParsePub {
105
- Yes ,
106
- No ,
107
- }
108
-
109
102
#[ derive( Clone , Copy , PartialEq ) ]
110
103
pub enum SemiColonMode {
111
104
Break ,
@@ -5111,20 +5104,17 @@ impl<'a> Parser<'a> {
5111
5104
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
5112
5105
} else {
5113
5106
// If we see: `struct Foo<T> where T: Copy { ... }`
5114
- VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: Yes ) ) ,
5115
- ast:: DUMMY_NODE_ID )
5107
+ VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) , ast:: DUMMY_NODE_ID )
5116
5108
}
5117
5109
// No `where` so: `struct Foo<T>;`
5118
5110
} else if self . eat ( & token:: Semi ) {
5119
5111
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
5120
5112
// Record-style struct definition
5121
5113
} else if self . token == token:: OpenDelim ( token:: Brace ) {
5122
- VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: Yes ) ) ,
5123
- ast:: DUMMY_NODE_ID )
5114
+ VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) , ast:: DUMMY_NODE_ID )
5124
5115
// Tuple-style struct definition with optional where-clause.
5125
5116
} else if self . token == token:: OpenDelim ( token:: Paren ) {
5126
- let body = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ParsePub :: Yes ) ) ,
5127
- ast:: DUMMY_NODE_ID ) ;
5117
+ let body = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ) ) , ast:: DUMMY_NODE_ID ) ;
5128
5118
generics. where_clause = try!( self . parse_where_clause ( ) ) ;
5129
5119
try!( self . expect ( & token:: Semi ) ) ;
5130
5120
body
@@ -5137,13 +5127,11 @@ impl<'a> Parser<'a> {
5137
5127
Ok ( ( class_name, ItemKind :: Struct ( vdata, generics) , None ) )
5138
5128
}
5139
5129
5140
- pub fn parse_record_struct_body ( & mut self ,
5141
- parse_pub : ParsePub )
5142
- -> PResult < ' a , Vec < StructField > > {
5130
+ pub fn parse_record_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
5143
5131
let mut fields = Vec :: new ( ) ;
5144
5132
if self . eat ( & token:: OpenDelim ( token:: Brace ) ) {
5145
5133
while self . token != token:: CloseDelim ( token:: Brace ) {
5146
- fields. push ( try!( self . parse_struct_decl_field ( parse_pub ) ) ) ;
5134
+ fields. push ( try!( self . parse_struct_decl_field ( ) ) ) ;
5147
5135
}
5148
5136
5149
5137
self . bump ( ) ;
@@ -5157,9 +5145,7 @@ impl<'a> Parser<'a> {
5157
5145
Ok ( fields)
5158
5146
}
5159
5147
5160
- pub fn parse_tuple_struct_body ( & mut self ,
5161
- parse_pub : ParsePub )
5162
- -> PResult < ' a , Vec < StructField > > {
5148
+ pub fn parse_tuple_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
5163
5149
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
5164
5150
// Unit like structs are handled in parse_item_struct function
5165
5151
let fields = try!( self . parse_unspanned_seq (
@@ -5170,13 +5156,7 @@ impl<'a> Parser<'a> {
5170
5156
let attrs = try!( p. parse_outer_attributes ( ) ) ;
5171
5157
let lo = p. span . lo ;
5172
5158
let struct_field_ = ast:: StructField_ {
5173
- kind : UnnamedField (
5174
- if parse_pub == ParsePub :: Yes {
5175
- try!( p. parse_visibility ( ) )
5176
- } else {
5177
- Visibility :: Inherited
5178
- }
5179
- ) ,
5159
+ kind : UnnamedField ( try!( p. parse_visibility ( ) ) ) ,
5180
5160
id : ast:: DUMMY_NODE_ID ,
5181
5161
ty : try!( p. parse_ty_sum ( ) ) ,
5182
5162
attrs : attrs,
@@ -5211,15 +5191,11 @@ impl<'a> Parser<'a> {
5211
5191
}
5212
5192
5213
5193
/// Parse an element of a struct definition
5214
- fn parse_struct_decl_field ( & mut self , parse_pub : ParsePub ) -> PResult < ' a , StructField > {
5194
+ fn parse_struct_decl_field ( & mut self ) -> PResult < ' a , StructField > {
5215
5195
5216
5196
let attrs = try!( self . parse_outer_attributes ( ) ) ;
5217
5197
5218
5198
if self . eat_keyword ( keywords:: Pub ) {
5219
- if parse_pub == ParsePub :: No {
5220
- let span = self . last_span ;
5221
- self . span_err ( span, "`pub` is not allowed here" ) ;
5222
- }
5223
5199
return self . parse_single_struct_field ( Visibility :: Public , attrs) ;
5224
5200
}
5225
5201
@@ -5585,11 +5561,11 @@ impl<'a> Parser<'a> {
5585
5561
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
5586
5562
// Parse a struct variant.
5587
5563
all_nullary = false ;
5588
- struct_def = VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: No ) ) ,
5564
+ struct_def = VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) ,
5589
5565
ast:: DUMMY_NODE_ID ) ;
5590
5566
} else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
5591
5567
all_nullary = false ;
5592
- struct_def = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ParsePub :: No ) ) ,
5568
+ struct_def = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ) ) ,
5593
5569
ast:: DUMMY_NODE_ID ) ;
5594
5570
} else if self . eat ( & token:: Eq ) {
5595
5571
disr_expr = Some ( try!( self . parse_expr ( ) ) ) ;
0 commit comments