1
Fork 0

implement hygiene for ExprFnBlock and ExprProc

This commit is contained in:
John Clements 2014-07-03 17:20:25 -07:00
parent ff9995e089
commit cc13f9bae8

View file

@ -229,6 +229,20 @@ pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
fld.cx.expr(e.span, ast::ExprLoop(loop_block, opt_ident)) fld.cx.expr(e.span, ast::ExprLoop(loop_block, opt_ident))
} }
ast::ExprFnBlock(fn_decl, block) => {
let (rewritten_fn_decl, rewritten_block)
= expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
let new_node = ast::ExprFnBlock(rewritten_fn_decl, rewritten_block);
box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
}
ast::ExprProc(fn_decl, block) => {
let (rewritten_fn_decl, rewritten_block)
= expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
let new_node = ast::ExprProc(rewritten_fn_decl, rewritten_block);
box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
}
_ => noop_fold_expr(e, fld) _ => noop_fold_expr(e, fld)
} }
} }
@ -1387,7 +1401,7 @@ mod test {
0) 0)
} }
// closure arg hygiene // closure arg hygiene (ExprFnBlock)
// expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);} // expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);}
#[test] fn closure_arg_hygiene(){ #[test] fn closure_arg_hygiene(){
run_renaming_test( run_renaming_test(