Skip to content

Commit

Permalink
Allow the expansion of old-style expr macros in stmt position.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulstansifer authored and graydon committed Nov 29, 2012
1 parent b7fcc9b commit ba354b1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -303,6 +303,24 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,

return (fully_expanded, sp)
}

Some(normal({expander: exp, span: exp_sp})) => {
//convert the new-style invoc for the old-style macro
let arg = base::tt_args_to_original_flavor(cx, pth.span, tts);
let exp_expr = exp(cx, mac.span, arg, None);
let expanded = @{node: ast::stmt_expr(exp_expr, cx.next_id()),
span: exp_expr.span};

cx.bt_push(ExpandedFrom({call_site: sp,
callie: {name: *extname,
span: exp_sp}}));
//keep going, outside-in
let fully_expanded = fld.fold_stmt(expanded).node;
cx.bt_pop();

(fully_expanded, sp)
}

_ => {
cx.span_fatal(pth.span,
fmt!("'%s' is not a tt-style macro",
Expand Down

0 comments on commit ba354b1

Please sign in to comment.