mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 00:53:48 +00:00
Recursively expand items, and keep expansion stack, per Paul's code review comments.
This commit is contained in:
parent
d09bcc0131
commit
84434bc084
@ -139,7 +139,7 @@ fn expand_item(exts: hashmap<str, syntax_extension>,
|
|||||||
};
|
};
|
||||||
let it = alt it.node {
|
let it = alt it.node {
|
||||||
ast::item_mac(*) {
|
ast::item_mac(*) {
|
||||||
expand_item_mac(exts, cx, it)
|
expand_item_mac(exts, cx, it, fld)
|
||||||
}
|
}
|
||||||
_ { it }
|
_ { it }
|
||||||
};
|
};
|
||||||
@ -150,7 +150,8 @@ fn expand_item(exts: hashmap<str, syntax_extension>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn expand_item_mac(exts: hashmap<str, syntax_extension>,
|
fn expand_item_mac(exts: hashmap<str, syntax_extension>,
|
||||||
cx: ext_ctxt, &&it: @ast::item) -> @ast::item {
|
cx: ext_ctxt, &&it: @ast::item,
|
||||||
|
fld: ast_fold) -> @ast::item {
|
||||||
alt it.node {
|
alt it.node {
|
||||||
item_mac({node: mac_invoc_tt(pth, tt), span}) {
|
item_mac({node: mac_invoc_tt(pth, tt), span}) {
|
||||||
let extname = pth.idents[0];
|
let extname = pth.idents[0];
|
||||||
@ -160,7 +161,13 @@ fn expand_item_mac(exts: hashmap<str, syntax_extension>,
|
|||||||
#fmt("macro undefined: '%s'", *extname))
|
#fmt("macro undefined: '%s'", *extname))
|
||||||
}
|
}
|
||||||
some(item_tt(expand)) {
|
some(item_tt(expand)) {
|
||||||
expand.expander(cx, it.span, it.ident, tt)
|
cx.bt_push(expanded_from({call_site: it.span,
|
||||||
|
callie: {name: *extname,
|
||||||
|
span: expand.span}}));
|
||||||
|
let it = fld.fold_item(
|
||||||
|
expand.expander(cx, it.span, it.ident, tt));
|
||||||
|
cx.bt_pop();
|
||||||
|
ret it
|
||||||
}
|
}
|
||||||
_ { cx.span_fatal(it.span,
|
_ { cx.span_fatal(it.span,
|
||||||
#fmt("%s is not a legal here", *extname)) }
|
#fmt("%s is not a legal here", *extname)) }
|
||||||
|
Loading…
Reference in New Issue
Block a user