@@ -934,6 +934,27 @@ impl<'a> Folder for PatIdentRenamer<'a> {
934934 }
935935}
936936
937+ // expand a method
938+ fn expand_method ( m : & ast:: Method , fld : & mut MacroExpander ) -> Gc < ast:: Method > {
939+ let id = fld. new_id ( m. id ) ;
940+ let ( rewritten_fn_decl, rewritten_body)
941+ = expand_and_rename_fn_decl_and_block ( m. decl , m. body , fld) ;
942+
943+ // all of the other standard stuff:
944+ box ( GC ) ast:: Method {
945+ id : id,
946+ ident : fld. fold_ident ( m. ident ) ,
947+ attrs : m. attrs . iter ( ) . map ( |a| fld. fold_attribute ( * a) ) . collect ( ) ,
948+ generics : fold_generics ( & m. generics , fld) ,
949+ explicit_self : fld. fold_explicit_self ( & m. explicit_self ) ,
950+ fn_style : m. fn_style ,
951+ decl : rewritten_fn_decl,
952+ body : rewritten_body,
953+ span : fld. new_span ( m. span ) ,
954+ vis : m. vis
955+ }
956+ }
957+
937958/// Given a fn_decl and a block and a MacroExpander, expand the fn_decl, then use the
938959/// PatIdents in its arguments to perform renaming in the FnDecl and
939960/// the block, returning both the new FnDecl and the new Block.
@@ -988,6 +1009,10 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
9881009 expand_arm ( arm, self )
9891010 }
9901011
1012+ fn fold_method ( & mut self , method : Gc < ast:: Method > ) -> Gc < ast:: Method > {
1013+ expand_method ( method, self )
1014+ }
1015+
9911016 fn new_span ( & mut self , span : Span ) -> Span {
9921017 new_span ( self . cx , span)
9931018 }
0 commit comments