diff options
| author | bors <bors@rust-lang.org> | 2014-08-14 03:46:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-14 03:46:22 +0000 |
| commit | 9d45d63d0d18f21f74c8a2a4e5367a785932f64e (patch) | |
| tree | b87ab6a2dd1256c5068314d0773dcf485c58a624 /src/libsyntax/ext | |
| parent | aa98b25c4f0c10729dff37c699904ad57b8fbda8 (diff) | |
| parent | a63003fe1aac487d3c0c527c4c984375c998de99 (diff) | |
| download | rust-9d45d63d0d18f21f74c8a2a4e5367a785932f64e.tar.gz rust-9d45d63d0d18f21f74c8a2a4e5367a785932f64e.zip | |
auto merge of #15929 : pcwalton/rust/by-ref-closures, r=alexcrichton
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12831. r? @alexcrichton
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 0e687c02c1d..f7eddca4b7a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -876,14 +876,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn lambda_fn_decl(&self, span: Span, fn_decl: P<ast::FnDecl>, blk: P<ast::Block>) -> Gc<ast::Expr> { - self.expr(span, ast::ExprFnBlock(fn_decl, blk)) + self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk)) } fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> Gc<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(fn_decl, blk)) + self.expr(span, ast::ExprFnBlock(ast::CaptureByRef, fn_decl, blk)) } fn lambda0(&self, span: Span, blk: P<ast::Block>) -> Gc<ast::Expr> { self.lambda(span, Vec::new(), blk) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 808532d55bb..d918b28d4dc 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -74,10 +74,12 @@ fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> { fld.cx.expr(e.span, ast::ExprForLoop(pat, head, body, opt_ident)) } - ast::ExprFnBlock(fn_decl, block) => { + ast::ExprFnBlock(capture_clause, 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); + let new_node = ast::ExprFnBlock(capture_clause, + rewritten_fn_decl, + rewritten_block); box(GC) ast::Expr{id:e.id, node: new_node, span: fld.new_span(e.span)} } |
