@@ -140,7 +140,7 @@ macro_rules! ast_fragments {
140140 AstFragment :: MethodReceiverExpr ( expr) => vis. visit_method_receiver_expr( expr) ,
141141 $( $( AstFragment :: $Kind( ast) => vis. $mut_visit_ast( ast) , ) ?) *
142142 $( $( AstFragment :: $Kind( ast) =>
143- ast. flat_map_in_place( |ast| vis. $flat_map_ast_elt( ast) ) , ) ?) *
143+ ast. flat_map_in_place( |ast| vis. $flat_map_ast_elt( ast, $ ( $args ) * ) ) , ) ?) *
144144 }
145145 }
146146
@@ -177,13 +177,13 @@ ast_fragments! {
177177 }
178178 TraitItems ( SmallVec <[ P <ast:: AssocItem >; 1 ] >) {
179179 "trait item" ;
180- many fn flat_map_trait_item ;
180+ many fn flat_map_assoc_item ;
181181 fn visit_assoc_item( AssocCtxt :: Trait ) ;
182182 fn make_trait_items;
183183 }
184184 ImplItems ( SmallVec <[ P <ast:: AssocItem >; 1 ] >) {
185185 "impl item" ;
186- many fn flat_map_impl_item ;
186+ many fn flat_map_assoc_item ;
187187 fn visit_assoc_item( AssocCtxt :: Impl ) ;
188188 fn make_impl_items;
189189 }
@@ -833,7 +833,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
833833 self . cx , deleg, & item, & suffixes, item. span , true ,
834834 ) ;
835835 fragment_kind. expect_from_annotatables (
836- single_delegations. map ( |item| Annotatable :: ImplItem ( P ( item) ) ) ,
836+ single_delegations. map ( |item| Annotatable :: AssocItem ( P ( item) , AssocCtxt :: Impl ) ) ,
837837 )
838838 }
839839 } )
@@ -843,8 +843,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
843843 fn gate_proc_macro_attr_item ( & self , span : Span , item : & Annotatable ) {
844844 let kind = match item {
845845 Annotatable :: Item ( _)
846- | Annotatable :: TraitItem ( _)
847- | Annotatable :: ImplItem ( _)
846+ | Annotatable :: AssocItem ( ..)
848847 | Annotatable :: ForeignItem ( _)
849848 | Annotatable :: Crate ( ..) => return ,
850849 Annotatable :: Stmt ( stmt) => {
@@ -1288,7 +1287,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
12881287 type ItemKind = AssocItemKind ;
12891288 const KIND : AstFragmentKind = AstFragmentKind :: TraitItems ;
12901289 fn to_annotatable ( self ) -> Annotatable {
1291- Annotatable :: TraitItem ( self . wrapped )
1290+ Annotatable :: AssocItem ( self . wrapped , AssocCtxt :: Trait )
12921291 }
12931292 fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
12941293 fragment. make_trait_items ( )
@@ -1329,7 +1328,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
13291328 type ItemKind = AssocItemKind ;
13301329 const KIND : AstFragmentKind = AstFragmentKind :: ImplItems ;
13311330 fn to_annotatable ( self ) -> Annotatable {
1332- Annotatable :: ImplItem ( self . wrapped )
1331+ Annotatable :: AssocItem ( self . wrapped , AssocCtxt :: Impl )
13331332 }
13341333 fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
13351334 fragment. make_impl_items ( )
@@ -1993,9 +1992,9 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19931992 let traitless_qself =
19941993 matches ! ( & deleg. qself, Some ( qself) if qself. position == 0 ) ;
19951994 let item = match node. to_annotatable ( ) {
1996- Annotatable :: ImplItem ( item) => item,
1995+ Annotatable :: AssocItem ( item, AssocCtxt :: Impl ) => item,
19971996 ann @ ( Annotatable :: Item ( _)
1998- | Annotatable :: TraitItem ( _ )
1997+ | Annotatable :: AssocItem ( .. )
19991998 | Annotatable :: Stmt ( _) ) => {
20001999 let span = ann. span ( ) ;
20012000 self . cx . dcx ( ) . emit_err ( GlobDelegationOutsideImpls { span } ) ;
@@ -2081,12 +2080,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
20812080 self . flat_map_node ( node)
20822081 }
20832082
2084- fn flat_map_trait_item ( & mut self , node : P < ast:: AssocItem > ) -> SmallVec < [ P < ast:: AssocItem > ; 1 ] > {
2085- self . flat_map_node ( AstNodeWrapper :: new ( node, TraitItemTag ) )
2086- }
2087-
2088- fn flat_map_impl_item ( & mut self , node : P < ast:: AssocItem > ) -> SmallVec < [ P < ast:: AssocItem > ; 1 ] > {
2089- self . flat_map_node ( AstNodeWrapper :: new ( node, ImplItemTag ) )
2083+ fn flat_map_assoc_item (
2084+ & mut self ,
2085+ node : P < ast:: AssocItem > ,
2086+ ctxt : AssocCtxt ,
2087+ ) -> SmallVec < [ P < ast:: AssocItem > ; 1 ] > {
2088+ match ctxt {
2089+ AssocCtxt :: Trait => self . flat_map_node ( AstNodeWrapper :: new ( node, TraitItemTag ) ) ,
2090+ AssocCtxt :: Impl => self . flat_map_node ( AstNodeWrapper :: new ( node, ImplItemTag ) ) ,
2091+ }
20902092 }
20912093
20922094 fn flat_map_foreign_item (
0 commit comments