File tree Expand file tree Collapse file tree 3 files changed +40
-11
lines changed
test/run-make/pretty-expanded Expand file tree Collapse file tree 3 files changed +40
-11
lines changed Original file line number Diff line number Diff line change @@ -1313,17 +1313,20 @@ impl<'a> State<'a> {
13131313 try!( self . print_fn_block_args ( decl) ) ;
13141314 try!( space ( & mut self . s ) ) ;
13151315 // }
1316- assert ! ( body. stmts. is_empty( ) ) ;
1317- assert ! ( body. expr. is_some( ) ) ;
1318- // we extract the block, so as not to create another set of boxes
1319- match body. expr . unwrap ( ) . node {
1320- ast:: ExprBlock ( blk) => {
1321- try!( self . print_block_unclosed ( blk) ) ;
1322- }
1323- _ => {
1324- // this is a bare expression
1325- try!( self . print_expr ( body. expr . unwrap ( ) ) ) ;
1326- try!( self . end ( ) ) ; // need to close a box
1316+
1317+ if !body. stmts . is_empty ( ) || !body. expr . is_some ( ) {
1318+ try!( self . print_block_unclosed ( body) ) ;
1319+ } else {
1320+ // we extract the block, so as not to create another set of boxes
1321+ match body. expr . unwrap ( ) . node {
1322+ ast:: ExprBlock ( blk) => {
1323+ try!( self . print_block_unclosed ( blk) ) ;
1324+ }
1325+ _ => {
1326+ // this is a bare expression
1327+ try!( self . print_expr ( body. expr . unwrap ( ) ) ) ;
1328+ try!( self . end ( ) ) ; // need to close a box
1329+ }
13271330 }
13281331 }
13291332 // a box will be closed by print_expr, but we didn't want an overall
Original file line number Diff line number Diff line change 1+ -include ../tools.mk
2+
3+ all :
4+ $(RUSTC ) -o $(TMPDIR ) /input.expanded.rs --pretty=expanded input.rs
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ crate_type="lib" ]
12+
13+ // #13544
14+
15+ extern crate serialize;
16+
17+ #[ deriving( Encodable ) ] pub struct A ;
18+ #[ deriving( Encodable ) ] pub struct B ( int ) ;
19+ #[ deriving( Encodable ) ] pub struct C { x : int }
20+ #[ deriving( Encodable ) ] pub enum D { }
21+ #[ deriving( Encodable ) ] pub enum E { y }
22+ #[ deriving( Encodable ) ] pub enum F { z( int ) }
You can’t perform that action at this time.
0 commit comments