diff options
| author | bors <bors@rust-lang.org> | 2014-04-16 05:11:26 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-16 05:11:26 -0700 |
| commit | 12391df5b78a7a904112c0056aa28773abecb65d (patch) | |
| tree | cbf475f1ed4e14705ad43f73337005251ed06cf8 /src/libsyntax | |
| parent | f39ba69aaa0b50d7aaa130306f3f12d89583d501 (diff) | |
| parent | 96710c11de32957fda9d0792664afeb936f18e78 (diff) | |
| download | rust-12391df5b78a7a904112c0056aa28773abecb65d.tar.gz rust-12391df5b78a7a904112c0056aa28773abecb65d.zip | |
auto merge of #13544 : klutzy/rust/pprust, r=alexcrichton
Fixes #12685
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index f2f0df00ee4..cedcb4e988b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1313,17 +1313,20 @@ impl<'a> State<'a> { try!(self.print_fn_block_args(decl)); try!(space(&mut self.s)); // } - assert!(body.stmts.is_empty()); - assert!(body.expr.is_some()); - // we extract the block, so as not to create another set of boxes - match body.expr.unwrap().node { - ast::ExprBlock(blk) => { - try!(self.print_block_unclosed(blk)); - } - _ => { - // this is a bare expression - try!(self.print_expr(body.expr.unwrap())); - try!(self.end()); // need to close a box + + 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.unwrap().node { + ast::ExprBlock(blk) => { + try!(self.print_block_unclosed(blk)); + } + _ => { + // this is a bare expression + try!(self.print_expr(body.expr.unwrap())); + try!(self.end()); // need to close a box + } } } // a box will be closed by print_expr, but we didn't want an overall |
