Skip to content

Commit 34015c3

Browse files
committed
add fold_mac clause to fun_to_ctxt_folder
1 parent 10baf2c commit 34015c3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,13 +1454,20 @@ pub fn fun_to_ctxt_folder<T : 'static + CtxtFn>(cf: @T) -> @AstFoldFns {
14541454
|ast::Ident{name, ctxt}, _| {
14551455
ast::Ident{name:name,ctxt:cf.f(ctxt)}
14561456
};
1457-
// we've also got to pick up macro invocations; they can
1458-
// appear as exprs, stmts, items, and types. urg, it's going
1459-
// to be easier just to add a fold_mac, I think.
1460-
//let fold_ex : @
1457+
let fm : @fn(&ast::mac_, span, @ast_fold) -> (ast::mac_,span) =
1458+
|m, sp, fld| {
1459+
match *m {
1460+
mac_invoc_tt(ref path, ref tts, ctxt) =>
1461+
(mac_invoc_tt(fld.fold_path(path),
1462+
fold_tts(*tts,fld),
1463+
cf.f(ctxt)),
1464+
sp)
1465+
}
1466+
1467+
};
14611468
@AstFoldFns{
14621469
fold_ident : fi,
1463-
// check that it works, then add the fold_expr clause....
1470+
fold_mac : fm,
14641471
.. *afp
14651472
}
14661473
}

0 commit comments

Comments
 (0)