@@ -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 ,
@@ -5093,20 +5086,17 @@ impl<'a> Parser<'a> {
5093
5086
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
5094
5087
} else {
5095
5088
// If we see: `struct Foo<T> where T: Copy { ... }`
5096
- VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: Yes ) ) ,
5097
- ast:: DUMMY_NODE_ID )
5089
+ VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) , ast:: DUMMY_NODE_ID )
5098
5090
}
5099
5091
// No `where` so: `struct Foo<T>;`
5100
5092
} else if self . eat ( & token:: Semi ) {
5101
5093
VariantData :: Unit ( ast:: DUMMY_NODE_ID )
5102
5094
// Record-style struct definition
5103
5095
} else if self . token == token:: OpenDelim ( token:: Brace ) {
5104
- VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: Yes ) ) ,
5105
- ast:: DUMMY_NODE_ID )
5096
+ VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) , ast:: DUMMY_NODE_ID )
5106
5097
// Tuple-style struct definition with optional where-clause.
5107
5098
} else if self . token == token:: OpenDelim ( token:: Paren ) {
5108
- let body = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ParsePub :: Yes ) ) ,
5109
- ast:: DUMMY_NODE_ID ) ;
5099
+ let body = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ) ) , ast:: DUMMY_NODE_ID ) ;
5110
5100
generics. where_clause = try!( self . parse_where_clause ( ) ) ;
5111
5101
try!( self . expect ( & token:: Semi ) ) ;
5112
5102
body
@@ -5119,13 +5109,11 @@ impl<'a> Parser<'a> {
5119
5109
Ok ( ( class_name, ItemKind :: Struct ( vdata, generics) , None ) )
5120
5110
}
5121
5111
5122
- pub fn parse_record_struct_body ( & mut self ,
5123
- parse_pub : ParsePub )
5124
- -> PResult < ' a , Vec < StructField > > {
5112
+ pub fn parse_record_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
5125
5113
let mut fields = Vec :: new ( ) ;
5126
5114
if self . eat ( & token:: OpenDelim ( token:: Brace ) ) {
5127
5115
while self . token != token:: CloseDelim ( token:: Brace ) {
5128
- fields. push ( try!( self . parse_struct_decl_field ( parse_pub ) ) ) ;
5116
+ fields. push ( try!( self . parse_struct_decl_field ( ) ) ) ;
5129
5117
}
5130
5118
5131
5119
self . bump ( ) ;
@@ -5139,9 +5127,7 @@ impl<'a> Parser<'a> {
5139
5127
Ok ( fields)
5140
5128
}
5141
5129
5142
- pub fn parse_tuple_struct_body ( & mut self ,
5143
- parse_pub : ParsePub )
5144
- -> PResult < ' a , Vec < StructField > > {
5130
+ pub fn parse_tuple_struct_body ( & mut self ) -> PResult < ' a , Vec < StructField > > {
5145
5131
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
5146
5132
// Unit like structs are handled in parse_item_struct function
5147
5133
let fields = try!( self . parse_unspanned_seq (
@@ -5152,13 +5138,7 @@ impl<'a> Parser<'a> {
5152
5138
let attrs = try!( p. parse_outer_attributes ( ) ) ;
5153
5139
let lo = p. span . lo ;
5154
5140
let struct_field_ = ast:: StructField_ {
5155
- kind : UnnamedField (
5156
- if parse_pub == ParsePub :: Yes {
5157
- try!( p. parse_visibility ( ) )
5158
- } else {
5159
- Visibility :: Inherited
5160
- }
5161
- ) ,
5141
+ kind : UnnamedField ( try!( p. parse_visibility ( ) ) ) ,
5162
5142
id : ast:: DUMMY_NODE_ID ,
5163
5143
ty : try!( p. parse_ty_sum ( ) ) ,
5164
5144
attrs : attrs,
@@ -5193,15 +5173,11 @@ impl<'a> Parser<'a> {
5193
5173
}
5194
5174
5195
5175
/// Parse an element of a struct definition
5196
- fn parse_struct_decl_field ( & mut self , parse_pub : ParsePub ) -> PResult < ' a , StructField > {
5176
+ fn parse_struct_decl_field ( & mut self ) -> PResult < ' a , StructField > {
5197
5177
5198
5178
let attrs = try!( self . parse_outer_attributes ( ) ) ;
5199
5179
5200
5180
if self . eat_keyword ( keywords:: Pub ) {
5201
- if parse_pub == ParsePub :: No {
5202
- let span = self . last_span ;
5203
- self . span_err ( span, "`pub` is not allowed here" ) ;
5204
- }
5205
5181
return self . parse_single_struct_field ( Visibility :: Public , attrs) ;
5206
5182
}
5207
5183
@@ -5567,11 +5543,11 @@ impl<'a> Parser<'a> {
5567
5543
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
5568
5544
// Parse a struct variant.
5569
5545
all_nullary = false ;
5570
- struct_def = VariantData :: Struct ( try!( self . parse_record_struct_body ( ParsePub :: No ) ) ,
5546
+ struct_def = VariantData :: Struct ( try!( self . parse_record_struct_body ( ) ) ,
5571
5547
ast:: DUMMY_NODE_ID ) ;
5572
5548
} else if self . check ( & token:: OpenDelim ( token:: Paren ) ) {
5573
5549
all_nullary = false ;
5574
- struct_def = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ParsePub :: No ) ) ,
5550
+ struct_def = VariantData :: Tuple ( try!( self . parse_tuple_struct_body ( ) ) ,
5575
5551
ast:: DUMMY_NODE_ID ) ;
5576
5552
} else if self . eat ( & token:: Eq ) {
5577
5553
disr_expr = Some ( try!( self . parse_expr ( ) ) ) ;
0 commit comments