diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-10-26 02:17:29 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-11-10 01:44:45 +0200 |
| commit | 49772fbf5dc1137a031086999b20ab7b961f3655 (patch) | |
| tree | 19ed6fae31552759225a7d4d11e52fa1c9153ade /src/libsyntax/parse | |
| parent | da2ce2276873242a101f205537e7ce297d68f8dd (diff) | |
| download | rust-49772fbf5dc1137a031086999b20ab7b961f3655.tar.gz rust-49772fbf5dc1137a031086999b20ab7b961f3655.zip | |
syntax: don't fake a block around closures' bodies during parsing.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b670a738473..7d15334ff9f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3162,25 +3162,12 @@ impl<'a> Parser<'a> { let decl = self.parse_fn_block_decl()?; let decl_hi = self.prev_span.hi; let body = match decl.output { - FunctionRetTy::Default(_) => { - // If no explicit return type is given, parse any - // expr and wrap it up in a dummy block: - let body_expr = self.parse_expr()?; - P(ast::Block { - id: ast::DUMMY_NODE_ID, - span: body_expr.span, - stmts: vec![Stmt { - span: body_expr.span, - node: StmtKind::Expr(body_expr), - id: ast::DUMMY_NODE_ID, - }], - rules: BlockCheckMode::Default, - }) - } + FunctionRetTy::Default(_) => self.parse_expr()?, _ => { // If an explicit return type is given, require a // block to appear (RFC 968). - self.parse_block()? + let body_lo = self.span.lo; + self.parse_block_expr(body_lo, BlockCheckMode::Default, ThinVec::new())? } }; |
