1
Fork 0

pprust: Handle multi-stmt/no-expr ExprFnBlock

Fixes #12685
This commit is contained in:
klutzy 2014-04-15 16:58:50 +09:00
parent 10f94e3fe5
commit 96710c11de
3 changed files with 40 additions and 11 deletions

View file

@ -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