@@ -724,11 +724,7 @@ fn expand_annotatable(a: Annotatable,
724724 -> SmallVector < Annotatable > {
725725 let a = expand_item_multi_modifier ( a, fld) ;
726726
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 {
732728 Annotatable :: Item ( it) => match it. node {
733729 ast:: ItemKind :: Mac ( ..) => {
734730 let new_items: SmallVector < P < ast:: Item > > = it. and_then ( |it| match it. node {
@@ -746,7 +742,7 @@ fn expand_annotatable(a: Annotatable,
746742 if valid_ident {
747743 fld. cx . mod_push ( it. ident ) ;
748744 }
749- let macro_use = contains_macro_use ( fld, & new_attrs [ .. ] ) ;
745+ let macro_use = contains_macro_use ( fld, & it . attrs ) ;
750746 let result = with_exts_frame ! ( fld. cx. syntax_env,
751747 macro_use,
752748 noop_fold_item( it, fld) ) ;
@@ -755,13 +751,7 @@ fn expand_annotatable(a: Annotatable,
755751 }
756752 result. into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( )
757753 } ,
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 ( ) ,
765755 } ,
766756
767757 Annotatable :: TraitItem ( it) => match it. node {
@@ -790,6 +780,17 @@ fn expand_annotatable(a: Annotatable,
790780 }
791781 } ;
792782
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) ) ;
793794 new_items. push_all ( decorator_items) ;
794795 new_items
795796}
0 commit comments