@@ -308,7 +308,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
308
308
err. emit ( ) ;
309
309
}
310
310
311
- let item = item
311
+ let item = self . fully_configure ( item)
312
312
. map_attrs ( |mut attrs| { attrs. retain ( |a| a. path != "derive" ) ; attrs } ) ;
313
313
let item_with_markers =
314
314
add_derived_markers ( & mut self . cx , item. span ( ) , & traits, item. clone ( ) ) ;
@@ -400,6 +400,27 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
400
400
result
401
401
}
402
402
403
+ fn fully_configure ( & mut self , item : Annotatable ) -> Annotatable {
404
+ let mut cfg = StripUnconfigured {
405
+ should_test : self . cx . ecfg . should_test ,
406
+ sess : self . cx . parse_sess ,
407
+ features : self . cx . ecfg . features ,
408
+ } ;
409
+ // Since the item itself has already been configured by the InvocationCollector,
410
+ // we know that fold result vector will contain exactly one element
411
+ match item {
412
+ Annotatable :: Item ( item) => {
413
+ Annotatable :: Item ( cfg. fold_item ( item) . pop ( ) . unwrap ( ) )
414
+ }
415
+ Annotatable :: TraitItem ( item) => {
416
+ Annotatable :: TraitItem ( item. map ( |item| cfg. fold_trait_item ( item) . pop ( ) . unwrap ( ) ) )
417
+ }
418
+ Annotatable :: ImplItem ( item) => {
419
+ Annotatable :: ImplItem ( item. map ( |item| cfg. fold_impl_item ( item) . pop ( ) . unwrap ( ) ) )
420
+ }
421
+ }
422
+ }
423
+
403
424
fn expand_invoc ( & mut self , invoc : Invocation , ext : Rc < SyntaxExtension > ) -> Expansion {
404
425
let result = match invoc. kind {
405
426
InvocationKind :: Bang { .. } => self . expand_bang_invoc ( invoc, ext) ,
@@ -740,15 +761,6 @@ struct InvocationCollector<'a, 'b: 'a> {
740
761
monotonic : bool ,
741
762
}
742
763
743
- macro_rules! fully_configure {
744
- ( $this: ident, $node: ident, $noop_fold: ident) => {
745
- match $noop_fold( $node, & mut $this. cfg) . pop( ) {
746
- Some ( node) => node,
747
- None => return SmallVector :: new( ) ,
748
- }
749
- }
750
- }
751
-
752
764
impl < ' a , ' b > InvocationCollector < ' a , ' b > {
753
765
fn collect ( & mut self , expansion_kind : ExpansionKind , kind : InvocationKind ) -> Expansion {
754
766
let mark = Mark :: fresh ( self . cx . current_expansion . mark ) ;
@@ -900,7 +912,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
900
912
901
913
let ( attr, traits, mut item) = self . classify_item ( item) ;
902
914
if attr. is_some ( ) || !traits. is_empty ( ) {
903
- let item = Annotatable :: Item ( fully_configure ! ( self , item, noop_fold_item ) ) ;
915
+ let item = Annotatable :: Item ( item) ;
904
916
return self . collect_attr ( attr, traits, item, ExpansionKind :: Items ) . make_items ( ) ;
905
917
}
906
918
@@ -974,8 +986,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
974
986
975
987
let ( attr, traits, item) = self . classify_item ( item) ;
976
988
if attr. is_some ( ) || !traits. is_empty ( ) {
977
- let item =
978
- Annotatable :: TraitItem ( P ( fully_configure ! ( self , item, noop_fold_trait_item) ) ) ;
989
+ let item = Annotatable :: TraitItem ( P ( item) ) ;
979
990
return self . collect_attr ( attr, traits, item, ExpansionKind :: TraitItems )
980
991
. make_trait_items ( )
981
992
}
@@ -995,7 +1006,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
995
1006
996
1007
let ( attr, traits, item) = self . classify_item ( item) ;
997
1008
if attr. is_some ( ) || !traits. is_empty ( ) {
998
- let item = Annotatable :: ImplItem ( P ( fully_configure ! ( self , item, noop_fold_impl_item ) ) ) ;
1009
+ let item = Annotatable :: ImplItem ( P ( item) ) ;
999
1010
return self . collect_attr ( attr, traits, item, ExpansionKind :: ImplItems )
1000
1011
. make_impl_items ( ) ;
1001
1012
}
0 commit comments