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/print/pprust.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/print/pprust.rs')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8e7804aaa71..5652a9a9d3a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -444,9 +444,8 @@ pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String { fn needs_parentheses(expr: &ast::Expr) -> bool { match expr.node { ast::ExprAssign(..) | ast::ExprBinary(..) | - ast::ExprFnBlock(..) | ast::ExprProc(..) | - ast::ExprUnboxedFn(..) | ast::ExprAssignOp(..) | - ast::ExprCast(..) => true, + ast::ExprClosure(..) | ast::ExprProc(..) | + ast::ExprAssignOp(..) | ast::ExprCast(..) => true, _ => false, } } @@ -1662,49 +1661,11 @@ impl<'a> State<'a> { } try!(self.bclose_(expr.span, indent_unit)); } - ast::ExprFnBlock(capture_clause, ref decl, ref body) => { + ast::ExprClosure(capture_clause, opt_kind, ref decl, ref body) => { try!(self.print_capture_clause(capture_clause)); - // in do/for blocks we don't want to show an empty - // argument list, but at this point we don't know which - // we are inside. - // - // if !decl.inputs.is_empty() { - try!(self.print_fn_block_args(&**decl, None)); + try!(self.print_fn_block_args(&**decl, opt_kind)); try!(space(&mut self.s)); - // } - - if !body.stmts.is_empty() || !body.expr.is_some() { - try!(self.print_block_unclosed(&**body)); - } else { - // we extract the block, so as not to create another set of boxes - match body.expr.as_ref().unwrap().node { - ast::ExprBlock(ref blk) => { - try!(self.print_block_unclosed(&**blk)); - } - _ => { - // this is a bare expression - try!(self.print_expr(&**body.expr.as_ref().unwrap())); - try!(self.end()); // need to close a box - } - } - } - // a box will be closed by print_expr, but we didn't want an overall - // wrapper so we closed the corresponding opening. so create an - // empty box to satisfy the close. - try!(self.ibox(0)); - } - ast::ExprUnboxedFn(capture_clause, kind, ref decl, ref body) => { - try!(self.print_capture_clause(capture_clause)); - - // in do/for blocks we don't want to show an empty - // argument list, but at this point we don't know which - // we are inside. - // - // if !decl.inputs.is_empty() { - try!(self.print_fn_block_args(&**decl, Some(kind))); - try!(space(&mut self.s)); - // } if !body.stmts.is_empty() || !body.expr.is_some() { try!(self.print_block_unclosed(&**body)); |
