diff options
| author | klutzy <klutzytheklutzy@gmail.com> | 2014-04-15 16:58:50 +0900 |
|---|---|---|
| committer | klutzy <klutzytheklutzy@gmail.com> | 2014-04-16 16:02:18 +0900 |
| commit | 96710c11de32957fda9d0792664afeb936f18e78 (patch) | |
| tree | d24d0ea0cf8bfb959677cc8d7fce74023128deb4 /src/libsyntax | |
| parent | 10f94e3fe5859fe7fc001cf26f4fa401d9a2ee2e (diff) | |
| download | rust-96710c11de32957fda9d0792664afeb936f18e78.tar.gz rust-96710c11de32957fda9d0792664afeb936f18e78.zip | |
pprust: Handle multi-stmt/no-expr `ExprFnBlock`
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 |
