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/parse/parser.rs | |
| 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/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a6fe3902395..ab0543d64b7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -25,10 +25,10 @@ use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, Explicit use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; use ast::{ExprBreak, ExprCall, ExprCast}; -use ast::{ExprField, ExprTupField, ExprFnBlock, ExprIf, ExprIfLet, ExprIndex, ExprSlice}; +use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex, ExprSlice}; use ast::{ExprLit, ExprLoop, ExprMac}; use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc}; -use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary, ExprUnboxedFn}; +use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary}; use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl}; use ast::{Once, Many}; use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind}; @@ -2999,7 +2999,8 @@ impl<'a> Parser<'a> { // `|args| expr` pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause) - -> P<Expr> { + -> P<Expr> + { let lo = self.span.lo; let (decl, optional_unboxed_closure_kind) = self.parse_fn_block_decl(); @@ -3013,21 +3014,10 @@ impl<'a> Parser<'a> { rules: DefaultBlock, }); - match optional_unboxed_closure_kind { - Some(unboxed_closure_kind) => { - self.mk_expr(lo, - fakeblock.span.hi, - ExprUnboxedFn(capture_clause, - unboxed_closure_kind, - decl, - fakeblock)) - } - None => { - self.mk_expr(lo, - fakeblock.span.hi, - ExprFnBlock(capture_clause, decl, fakeblock)) - } - } + self.mk_expr( + lo, + fakeblock.span.hi, + ExprClosure(capture_clause, optional_unboxed_closure_kind, decl, fakeblock)) } pub fn parse_else_expr(&mut self) -> P<Expr> { |
