@@ -25,21 +25,15 @@ pub(super) type ItemInfo = (Ident, ItemKind);
2525
2626impl < ' a > Parser < ' a > {
2727 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 ) )
3029 }
3130
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)
4034 }
4135
42- fn parse_item_common (
36+ pub ( super ) fn parse_item_common (
4337 & mut self ,
4438 mut attrs : Vec < Attribute > ,
4539 mac_allowed : bool ,
@@ -653,9 +647,7 @@ impl<'a> Parser<'a> {
653647
654648 /// Parses associated items.
655649 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 } | {
659651 let kind = match kind {
660652 ItemKind :: Mac ( a) => AssocItemKind :: Macro ( a) ,
661653 ItemKind :: Fn ( a, b, c, d) => AssocItemKind :: Fn ( a, b, c, d) ,
@@ -844,9 +836,7 @@ impl<'a> Parser<'a> {
844836 pub fn parse_foreign_item ( & mut self ) -> PResult < ' a , Option < Option < P < ForeignItem > > > > {
845837 maybe_whole ! ( self , NtForeignItem , |item| Some ( Some ( item) ) ) ;
846838
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 } | {
850840 let kind = match kind {
851841 ItemKind :: Mac ( a) => ForeignItemKind :: Macro ( a) ,
852842 ItemKind :: Fn ( a, b, c, d) => ForeignItemKind :: Fn ( a, b, c, d) ,
0 commit comments