@@ -81,8 +81,11 @@ impl_macro_generable! {
81
81
"statement" , . make_stmts, lift . fold_stmt, lift . visit_stmt, |_span| SmallVector :: zero( ) ;
82
82
SmallVector <P <ast:: Item >>:
83
83
"item" , . make_items, lift . fold_item, lift . visit_item, |_span| SmallVector :: zero( ) ;
84
+ SmallVector <ast:: TraitItem >:
85
+ "trait item" , . make_trait_items, lift . fold_trait_item, lift . visit_trait_item,
86
+ |_span| SmallVector :: zero( ) ;
84
87
SmallVector <ast:: ImplItem >:
85
- "impl item" , . make_impl_items, lift . fold_impl_item, lift . visit_impl_item,
88
+ "impl item" , . make_impl_items, lift . fold_impl_item, lift . visit_impl_item,
86
89
|_span| SmallVector :: zero( ) ;
87
90
}
88
91
@@ -754,25 +757,10 @@ fn expand_multi_modified(a: Annotatable, fld: &mut MacroExpander) -> SmallVector
754
757
_ => noop_fold_item ( it, fld) ,
755
758
} . into_iter ( ) . map ( |i| Annotatable :: Item ( i) ) . collect ( ) ,
756
759
757
- Annotatable :: TraitItem ( it) => match it. node {
758
- ast:: TraitItemKind :: Method ( _, Some ( _) ) => {
759
- let ti = it. unwrap ( ) ;
760
- SmallVector :: one ( ast:: TraitItem {
761
- id : ti. id ,
762
- ident : ti. ident ,
763
- attrs : ti. attrs ,
764
- node : match ti. node {
765
- ast:: TraitItemKind :: Method ( sig, Some ( body) ) => {
766
- let ( sig, body) = expand_and_rename_method ( sig, body, fld) ;
767
- ast:: TraitItemKind :: Method ( sig, Some ( body) )
768
- }
769
- _ => unreachable ! ( )
770
- } ,
771
- span : ti. span ,
772
- } )
773
- }
774
- _ => fold:: noop_fold_trait_item ( it. unwrap ( ) , fld)
775
- } . into_iter ( ) . map ( |ti| Annotatable :: TraitItem ( P ( ti) ) ) . collect ( ) ,
760
+ Annotatable :: TraitItem ( it) => {
761
+ expand_trait_item ( it. unwrap ( ) , fld) . into_iter ( ) .
762
+ map ( |it| Annotatable :: TraitItem ( P ( it) ) ) . collect ( )
763
+ }
776
764
777
765
Annotatable :: ImplItem ( ii) => {
778
766
expand_impl_item ( ii. unwrap ( ) , fld) . into_iter ( ) .
@@ -900,6 +888,31 @@ fn expand_impl_item(ii: ast::ImplItem, fld: &mut MacroExpander)
900
888
}
901
889
}
902
890
891
+ fn expand_trait_item ( ti : ast:: TraitItem , fld : & mut MacroExpander )
892
+ -> SmallVector < ast:: TraitItem > {
893
+ match ti. node {
894
+ ast:: TraitItemKind :: Method ( _, Some ( _) ) => {
895
+ SmallVector :: one ( ast:: TraitItem {
896
+ id : ti. id ,
897
+ ident : ti. ident ,
898
+ attrs : ti. attrs ,
899
+ node : match ti. node {
900
+ ast:: TraitItemKind :: Method ( sig, Some ( body) ) => {
901
+ let ( sig, body) = expand_and_rename_method ( sig, body, fld) ;
902
+ ast:: TraitItemKind :: Method ( sig, Some ( body) )
903
+ }
904
+ _ => unreachable ! ( )
905
+ } ,
906
+ span : ti. span ,
907
+ } )
908
+ }
909
+ ast:: TraitItemKind :: Macro ( mac) => {
910
+ expand_mac_invoc ( mac, None , ti. attrs , ti. span , fld)
911
+ }
912
+ _ => fold:: noop_fold_trait_item ( ti, fld)
913
+ }
914
+ }
915
+
903
916
/// Given a fn_decl and a block and a MacroExpander, expand the fn_decl, then use the
904
917
/// PatIdents in its arguments to perform renaming in the FnDecl and
905
918
/// the block, returning both the new FnDecl and the new Block.
0 commit comments