@@ -724,11 +724,7 @@ fn expand_annotatable(a: Annotatable,
724
724
-> SmallVector < Annotatable > {
725
725
let a = expand_item_multi_modifier ( a, fld) ;
726
726
727
- let mut decorator_items = SmallVector :: zero ( ) ;
728
- let mut new_attrs = Vec :: new ( ) ;
729
- expand_decorators ( a. clone ( ) , fld, & mut decorator_items, & mut new_attrs) ;
730
-
731
- let mut new_items: SmallVector < Annotatable > = match a {
727
+ let new_items: SmallVector < Annotatable > = match a {
732
728
Annotatable :: Item ( it) => match it. node {
733
729
ast:: ItemKind :: Mac ( ..) => {
734
730
let new_items: SmallVector < P < ast:: Item > > = it. and_then ( |it| match it. node {
@@ -746,7 +742,7 @@ fn expand_annotatable(a: Annotatable,
746
742
if valid_ident {
747
743
fld. cx . mod_push ( it. ident ) ;
748
744
}
749
- let macro_use = contains_macro_use ( fld, & new_attrs [ .. ] ) ;
745
+ let macro_use = contains_macro_use ( fld, & it . attrs ) ;
750
746
let result = with_exts_frame ! ( fld. cx. syntax_env,
751
747
macro_use,
752
748
noop_fold_item( it, fld) ) ;
@@ -755,13 +751,7 @@ fn expand_annotatable(a: Annotatable,
755
751
}
756
752
result. into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( )
757
753
} ,
758
- _ => {
759
- let it = P ( ast:: Item {
760
- attrs : new_attrs,
761
- ..( * it) . clone ( )
762
- } ) ;
763
- noop_fold_item ( it, fld) . into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( )
764
- }
754
+ _ => noop_fold_item ( it, fld) . into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( ) ,
765
755
} ,
766
756
767
757
Annotatable :: TraitItem ( it) => match it. node {
@@ -790,6 +780,17 @@ fn expand_annotatable(a: Annotatable,
790
780
}
791
781
} ;
792
782
783
+ new_items. into_iter ( ) . flat_map ( |a| decorate ( a, fld) ) . collect ( )
784
+ }
785
+
786
+ fn decorate ( a : Annotatable , fld : & mut MacroExpander ) -> SmallVector < Annotatable > {
787
+ let mut decorator_items = SmallVector :: zero ( ) ;
788
+ let mut new_attrs = Vec :: new ( ) ;
789
+ expand_decorators ( a. clone ( ) , fld, & mut decorator_items, & mut new_attrs) ;
790
+ let decorator_items =
791
+ decorator_items. into_iter ( ) . flat_map ( |a| expand_annotatable ( a, fld) ) . collect ( ) ;
792
+
793
+ let mut new_items = SmallVector :: one ( a. fold_attrs ( new_attrs) ) ;
793
794
new_items. push_all ( decorator_items) ;
794
795
new_items
795
796
}
0 commit comments