@@ -25,21 +25,15 @@ pub(super) type ItemInfo = (Ident, ItemKind);
25
25
26
26
impl < ' a > Parser < ' a > {
27
27
pub fn parse_item ( & mut self ) -> PResult < ' a , Option < P < Item > > > {
28
- let attrs = self . parse_outer_attributes ( ) ?;
29
- self . parse_item_ ( attrs, true , false )
28
+ self . parse_item_ ( |_| true ) . map ( |i| i. map ( P ) )
30
29
}
31
30
32
- pub ( super ) fn parse_item_ (
33
- & mut self ,
34
- attrs : Vec < Attribute > ,
35
- macros_allowed : bool ,
36
- attributes_allowed : bool ,
37
- ) -> PResult < ' a , Option < P < Item > > > {
38
- let item = self . parse_item_common ( attrs, macros_allowed, attributes_allowed, |_| true ) ?;
39
- Ok ( item. map ( P ) )
31
+ fn parse_item_ ( & mut self , req_name : ReqName ) -> PResult < ' a , Option < Item > > {
32
+ let attrs = self . parse_outer_attributes ( ) ?;
33
+ self . parse_item_common ( attrs, true , false , req_name)
40
34
}
41
35
42
- fn parse_item_common (
36
+ pub ( super ) fn parse_item_common (
43
37
& mut self ,
44
38
mut attrs : Vec < Attribute > ,
45
39
mac_allowed : bool ,
@@ -653,9 +647,7 @@ impl<'a> Parser<'a> {
653
647
654
648
/// Parses associated items.
655
649
fn parse_assoc_item ( & mut self , req_name : ReqName ) -> PResult < ' a , Option < Option < P < AssocItem > > > > {
656
- let attrs = self . parse_outer_attributes ( ) ?;
657
- let it = self . parse_item_common ( attrs, true , false , req_name) ?;
658
- Ok ( it. map ( |Item { attrs, id, span, vis, ident, kind, tokens } | {
650
+ Ok ( self . parse_item_ ( req_name) ?. map ( |Item { attrs, id, span, vis, ident, kind, tokens } | {
659
651
let kind = match kind {
660
652
ItemKind :: Mac ( a) => AssocItemKind :: Macro ( a) ,
661
653
ItemKind :: Fn ( a, b, c, d) => AssocItemKind :: Fn ( a, b, c, d) ,
@@ -844,9 +836,7 @@ impl<'a> Parser<'a> {
844
836
pub fn parse_foreign_item ( & mut self ) -> PResult < ' a , Option < Option < P < ForeignItem > > > > {
845
837
maybe_whole ! ( self , NtForeignItem , |item| Some ( Some ( item) ) ) ;
846
838
847
- let attrs = self . parse_outer_attributes ( ) ?;
848
- let item = self . parse_item_common ( attrs, true , false , |_| true ) ?;
849
- Ok ( item. map ( |Item { attrs, id, span, vis, ident, kind, tokens } | {
839
+ Ok ( self . parse_item_ ( |_| true ) ?. map ( |Item { attrs, id, span, vis, ident, kind, tokens } | {
850
840
let kind = match kind {
851
841
ItemKind :: Mac ( a) => ForeignItemKind :: Macro ( a) ,
852
842
ItemKind :: Fn ( a, b, c, d) => ForeignItemKind :: Fn ( a, b, c, d) ,
0 commit comments