From 3e2929d3623dd4c4d601a31e55e9d36dba7afe88 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 19 Nov 2014 11:18:17 -0500 Subject: Merge the ExprFnBlock and ExprUnboxedClosure into one ExprClosure with an optional unboxed closure kind. --- src/libsyntax/ext/build.rs | 4 ++-- src/libsyntax/ext/expand.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index ffc42b67033..b18a0c8411c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -864,14 +864,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn lambda_fn_decl(&self, span: Span, fn_decl: P, blk: P) -> P { - self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk)) + self.expr(span, ast::ExprClosure(ast::CaptureByRef, None, fn_decl, blk)) } fn lambda(&self, span: Span, ids: Vec, blk: P) -> P { let fn_decl = self.fn_decl( ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(), self.ty_infer(span)); - self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk)) + self.expr(span, ast::ExprClosure(ast::CaptureByRef, None, fn_decl, blk)) } fn lambda0(&self, span: Span, blk: P) -> P { self.lambda(span, Vec::new(), blk) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 081456bebe1..04132679a03 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -207,10 +207,11 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { fld.cx.expr(span, ast::ExprForLoop(pat, head, body, opt_ident)) } - ast::ExprFnBlock(capture_clause, fn_decl, block) => { + ast::ExprClosure(capture_clause, opt_kind, 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(capture_clause, + let new_node = ast::ExprClosure(capture_clause, + opt_kind, rewritten_fn_decl, rewritten_block); P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)}) @@ -1555,7 +1556,7 @@ mod test { 0) } - // closure arg hygiene (ExprFnBlock) + // closure arg hygiene (ExprClosure) // expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);} #[test] fn closure_arg_hygiene(){ run_renaming_test( -- cgit 1.4.1-3-g733a5