@@ -128,52 +128,41 @@ impl<'a> Parser<'a> {
128
128
Some ( item. into_inner( ) )
129
129
} ) ;
130
130
131
- self . collect_tokens_trailing_token ( attrs, force_collect, |this, attrs| {
132
- let item = this. parse_item_common_ ( attrs, mac_allowed, attrs_allowed, fn_parse_mode) ?;
133
- Ok ( ( item, TrailingToken :: None ) )
134
- } )
135
- }
136
-
137
- fn parse_item_common_ (
138
- & mut self ,
139
- mut attrs : AttrVec ,
140
- mac_allowed : bool ,
141
- attrs_allowed : bool ,
142
- fn_parse_mode : FnParseMode ,
143
- ) -> PResult < ' a , Option < Item > > {
144
- let lo = self . token . span ;
145
- let vis = self . parse_visibility ( FollowedByType :: No ) ?;
146
- let mut def = self . parse_defaultness ( ) ;
147
- let kind = self . parse_item_kind (
148
- & mut attrs,
149
- mac_allowed,
150
- lo,
151
- & vis,
152
- & mut def,
153
- fn_parse_mode,
154
- Case :: Sensitive ,
155
- ) ?;
156
- if let Some ( ( ident, kind) ) = kind {
157
- self . error_on_unconsumed_default ( def, & kind) ;
158
- let span = lo. to ( self . prev_token . span ) ;
159
- let id = DUMMY_NODE_ID ;
160
- let item = Item { ident, attrs, id, kind, vis, span, tokens : None } ;
161
- return Ok ( Some ( item) ) ;
162
- }
131
+ self . collect_tokens_trailing_token ( attrs, force_collect, |this, mut attrs| {
132
+ let lo = this. token . span ;
133
+ let vis = this. parse_visibility ( FollowedByType :: No ) ?;
134
+ let mut def = this. parse_defaultness ( ) ;
135
+ let kind = this. parse_item_kind (
136
+ & mut attrs,
137
+ mac_allowed,
138
+ lo,
139
+ & vis,
140
+ & mut def,
141
+ fn_parse_mode,
142
+ Case :: Sensitive ,
143
+ ) ?;
144
+ if let Some ( ( ident, kind) ) = kind {
145
+ this. error_on_unconsumed_default ( def, & kind) ;
146
+ let span = lo. to ( this. prev_token . span ) ;
147
+ let id = DUMMY_NODE_ID ;
148
+ let item = Item { ident, attrs, id, kind, vis, span, tokens : None } ;
149
+ return Ok ( ( Some ( item) , TrailingToken :: None ) ) ;
150
+ }
163
151
164
- // At this point, we have failed to parse an item.
165
- if !matches ! ( vis. kind, VisibilityKind :: Inherited ) {
166
- self . dcx ( ) . emit_err ( errors:: VisibilityNotFollowedByItem { span : vis. span , vis } ) ;
167
- }
152
+ // At this point, we have failed to parse an item.
153
+ if !matches ! ( vis. kind, VisibilityKind :: Inherited ) {
154
+ this . dcx ( ) . emit_err ( errors:: VisibilityNotFollowedByItem { span : vis. span , vis } ) ;
155
+ }
168
156
169
- if let Defaultness :: Default ( span) = def {
170
- self . dcx ( ) . emit_err ( errors:: DefaultNotFollowedByItem { span } ) ;
171
- }
157
+ if let Defaultness :: Default ( span) = def {
158
+ this . dcx ( ) . emit_err ( errors:: DefaultNotFollowedByItem { span } ) ;
159
+ }
172
160
173
- if !attrs_allowed {
174
- self . recover_attrs_no_item ( & attrs) ?;
175
- }
176
- Ok ( None )
161
+ if !attrs_allowed {
162
+ this. recover_attrs_no_item ( & attrs) ?;
163
+ }
164
+ Ok ( ( None , TrailingToken :: None ) )
165
+ } )
177
166
}
178
167
179
168
/// Error in-case `default` was parsed in an in-appropriate context.
0 commit comments