From 2c51e262f367f0f079135a5a176706ea5ef78f78 Mon Sep 17 00:00:00 2001 From: John Clements Date: Mon, 8 Jul 2013 10:37:07 -0700 Subject: [PATCH] add fold_mac clause to fun_to_ctxt_folder --- src/libsyntax/ext/expand.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 228a9ba03a27..a62b015c6cbb 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1454,13 +1454,20 @@ pub fn fun_to_ctxt_folder(cf: @T) -> @AstFoldFns { |ast::Ident{name, ctxt}, _| { ast::Ident{name:name,ctxt:cf.f(ctxt)} }; - // we've also got to pick up macro invocations; they can - // appear as exprs, stmts, items, and types. urg, it's going - // to be easier just to add a fold_mac, I think. - //let fold_ex : @ + let fm : @fn(&ast::mac_, span, @ast_fold) -> (ast::mac_,span) = + |m, sp, fld| { + match *m { + mac_invoc_tt(ref path, ref tts, ctxt) => + (mac_invoc_tt(fld.fold_path(path), + fold_tts(*tts,fld), + cf.f(ctxt)), + sp) + } + + }; @AstFoldFns{ fold_ident : fi, - // check that it works, then add the fold_expr clause.... + fold_mac : fm, .. *afp } }