diff options
| author | bors <bors@rust-lang.org> | 2014-11-20 12:01:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-20 12:01:44 +0000 |
| commit | 1d81776209cfa2b5cb1825bdbf3965a7a7f0440a (patch) | |
| tree | 43c3aa55ebfb5fd8b24173e1315a4212346bbd8f /src/libsyntax/ext | |
| parent | b825b3496aff1ed784f7a7ca935245208b95aabb (diff) | |
| parent | b9c5cd4dc420b90874784b253bcb8fd4ac72441a (diff) | |
| download | rust-1d81776209cfa2b5cb1825bdbf3965a7a7f0440a.tar.gz rust-1d81776209cfa2b5cb1825bdbf3965a7a7f0440a.zip | |
auto merge of #19113 : nikomatsakis/rust/unboxed-boxed-closure-unification, r=acrichto
Use the expected type to infer the argument/return types of unboxed closures. Also, in `||` expressions, use the expected type to decide if the result should be a boxed or unboxed closure (and if an unboxed closure, what kind). This supercedes PR #19089, which was already reviewed by @pcwalton.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 7 |
2 files changed, 6 insertions, 5 deletions
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<ast::FnDecl>, blk: P<ast::Block>) -> P<ast::Expr> { - 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<ast::Ident>, blk: P<ast::Block>) -> P<ast::Expr> { 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<ast::Block>) -> P<ast::Expr> { 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<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> { 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( |
