@@ -140,7 +140,7 @@ macro_rules! ast_fragments {
140
140
AstFragment :: MethodReceiverExpr ( expr) => vis. visit_method_receiver_expr( expr) ,
141
141
$( $( AstFragment :: $Kind( ast) => vis. $mut_visit_ast( ast) , ) ?) *
142
142
$( $( 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 ) * ) ) , ) ?) *
144
144
}
145
145
}
146
146
@@ -177,13 +177,13 @@ ast_fragments! {
177
177
}
178
178
TraitItems ( SmallVec <[ P <ast:: AssocItem >; 1 ] >) {
179
179
"trait item" ;
180
- many fn flat_map_trait_item ;
180
+ many fn flat_map_assoc_item ;
181
181
fn visit_assoc_item( AssocCtxt :: Trait ) ;
182
182
fn make_trait_items;
183
183
}
184
184
ImplItems ( SmallVec <[ P <ast:: AssocItem >; 1 ] >) {
185
185
"impl item" ;
186
- many fn flat_map_impl_item ;
186
+ many fn flat_map_assoc_item ;
187
187
fn visit_assoc_item( AssocCtxt :: Impl ) ;
188
188
fn make_impl_items;
189
189
}
@@ -833,7 +833,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
833
833
self . cx , deleg, & item, & suffixes, item. span , true ,
834
834
) ;
835
835
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 ) ) ,
837
837
)
838
838
}
839
839
} )
@@ -843,8 +843,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
843
843
fn gate_proc_macro_attr_item ( & self , span : Span , item : & Annotatable ) {
844
844
let kind = match item {
845
845
Annotatable :: Item ( _)
846
- | Annotatable :: TraitItem ( _)
847
- | Annotatable :: ImplItem ( _)
846
+ | Annotatable :: AssocItem ( ..)
848
847
| Annotatable :: ForeignItem ( _)
849
848
| Annotatable :: Crate ( ..) => return ,
850
849
Annotatable :: Stmt ( stmt) => {
@@ -1288,7 +1287,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
1288
1287
type ItemKind = AssocItemKind ;
1289
1288
const KIND : AstFragmentKind = AstFragmentKind :: TraitItems ;
1290
1289
fn to_annotatable ( self ) -> Annotatable {
1291
- Annotatable :: TraitItem ( self . wrapped )
1290
+ Annotatable :: AssocItem ( self . wrapped , AssocCtxt :: Trait )
1292
1291
}
1293
1292
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1294
1293
fragment. make_trait_items ( )
@@ -1329,7 +1328,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
1329
1328
type ItemKind = AssocItemKind ;
1330
1329
const KIND : AstFragmentKind = AstFragmentKind :: ImplItems ;
1331
1330
fn to_annotatable ( self ) -> Annotatable {
1332
- Annotatable :: ImplItem ( self . wrapped )
1331
+ Annotatable :: AssocItem ( self . wrapped , AssocCtxt :: Impl )
1333
1332
}
1334
1333
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1335
1334
fragment. make_impl_items ( )
@@ -1993,9 +1992,9 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1993
1992
let traitless_qself =
1994
1993
matches ! ( & deleg. qself, Some ( qself) if qself. position == 0 ) ;
1995
1994
let item = match node. to_annotatable ( ) {
1996
- Annotatable :: ImplItem ( item) => item,
1995
+ Annotatable :: AssocItem ( item, AssocCtxt :: Impl ) => item,
1997
1996
ann @ ( Annotatable :: Item ( _)
1998
- | Annotatable :: TraitItem ( _ )
1997
+ | Annotatable :: AssocItem ( .. )
1999
1998
| Annotatable :: Stmt ( _) ) => {
2000
1999
let span = ann. span ( ) ;
2001
2000
self . cx . dcx ( ) . emit_err ( GlobDelegationOutsideImpls { span } ) ;
@@ -2081,12 +2080,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
2081
2080
self . flat_map_node ( node)
2082
2081
}
2083
2082
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
+ }
2090
2092
}
2091
2093
2092
2094
fn flat_map_foreign_item (
0 commit comments