Skip to content

Commit cc13f9b

Browse files
committed
implement hygiene for ExprFnBlock and ExprProc
1 parent ff9995e commit cc13f9b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/libsyntax/ext/expand.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
229229
fld.cx.expr(e.span, ast::ExprLoop(loop_block, opt_ident))
230230
}
231231

232+
ast::ExprFnBlock(fn_decl, block) => {
233+
let (rewritten_fn_decl, rewritten_block)
234+
= expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
235+
let new_node = ast::ExprFnBlock(rewritten_fn_decl, rewritten_block);
236+
box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
237+
}
238+
239+
ast::ExprProc(fn_decl, block) => {
240+
let (rewritten_fn_decl, rewritten_block)
241+
= expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
242+
let new_node = ast::ExprProc(rewritten_fn_decl, rewritten_block);
243+
box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)}
244+
}
245+
232246
_ => noop_fold_expr(e, fld)
233247
}
234248
}
@@ -1387,7 +1401,7 @@ mod test {
13871401
0)
13881402
}
13891403

1390-
// closure arg hygiene
1404+
// closure arg hygiene (ExprFnBlock)
13911405
// expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);}
13921406
#[test] fn closure_arg_hygiene(){
13931407
run_renaming_test(

0 commit comments

Comments
 (0)