@@ -723,11 +723,7 @@ fn expand_annotatable(a: Annotatable,
723723 -> SmallVector < Annotatable > {
724724 let a = expand_item_multi_modifier ( a, fld) ;
725725
726- let mut decorator_items = SmallVector :: zero ( ) ;
727- let mut new_attrs = Vec :: new ( ) ;
728- expand_decorators ( a. clone ( ) , fld, & mut decorator_items, & mut new_attrs) ;
729-
730- let mut new_items: SmallVector < Annotatable > = match a {
726+ let new_items: SmallVector < Annotatable > = match a {
731727 Annotatable :: Item ( it) => match it. node {
732728 ast:: ItemKind :: Mac ( ..) => {
733729 let new_items: SmallVector < P < ast:: Item > > = it. and_then ( |it| match it. node {
@@ -745,7 +741,7 @@ fn expand_annotatable(a: Annotatable,
745741 if valid_ident {
746742 fld. cx . mod_push ( it. ident ) ;
747743 }
748- let macro_use = contains_macro_use ( fld, & new_attrs [ .. ] ) ;
744+ let macro_use = contains_macro_use ( fld, & it . attrs ) ;
749745 let result = with_exts_frame ! ( fld. cx. syntax_env,
750746 macro_use,
751747 noop_fold_item( it, fld) ) ;
@@ -754,13 +750,7 @@ fn expand_annotatable(a: Annotatable,
754750 }
755751 result. into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( )
756752 } ,
757- _ => {
758- let it = P ( ast:: Item {
759- attrs : new_attrs,
760- ..( * it) . clone ( )
761- } ) ;
762- noop_fold_item ( it, fld) . into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( )
763- }
753+ _ => noop_fold_item ( it, fld) . into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( ) ,
764754 } ,
765755
766756 Annotatable :: TraitItem ( it) => match it. node {
@@ -789,6 +779,17 @@ fn expand_annotatable(a: Annotatable,
789779 }
790780 } ;
791781
782+ new_items. into_iter ( ) . flat_map ( |a| decorate ( a, fld) ) . collect ( )
783+ }
784+
785+ fn decorate ( a : Annotatable , fld : & mut MacroExpander ) -> SmallVector < Annotatable > {
786+ let mut decorator_items = SmallVector :: zero ( ) ;
787+ let mut new_attrs = Vec :: new ( ) ;
788+ expand_decorators ( a. clone ( ) , fld, & mut decorator_items, & mut new_attrs) ;
789+ let decorator_items =
790+ decorator_items. into_iter ( ) . flat_map ( |a| expand_annotatable ( a, fld) ) . collect ( ) ;
791+
792+ let mut new_items = SmallVector :: one ( a. fold_attrs ( new_attrs) ) ;
792793 new_items. push_all ( decorator_items) ;
793794 new_items
794795}
0 commit comments