@@ -992,8 +992,23 @@ impl<'a> State<'a> {
992
992
pub fn print_stmt ( & mut self , st : & hir:: Stmt ) -> io:: Result < ( ) > {
993
993
self . maybe_print_comment ( st. span . lo ( ) ) ?;
994
994
match st. node {
995
- hir:: StmtKind :: Decl ( ref decl) => {
996
- self . print_decl ( & decl) ?;
995
+ hir:: StmtKind :: Local ( ref loc) => {
996
+ self . space_if_not_bol ( ) ?;
997
+ self . ibox ( indent_unit) ?;
998
+ self . word_nbsp ( "let" ) ?;
999
+
1000
+ self . ibox ( indent_unit) ?;
1001
+ self . print_local_decl ( & loc) ?;
1002
+ self . end ( ) ?;
1003
+ if let Some ( ref init) = loc. init {
1004
+ self . nbsp ( ) ?;
1005
+ self . word_space ( "=" ) ?;
1006
+ self . print_expr ( & init) ?;
1007
+ }
1008
+ self . end ( ) ?
1009
+ }
1010
+ hir:: StmtKind :: Item ( ref item) => {
1011
+ self . ann . nested ( self , Nested :: Item ( * * item) ) ?
997
1012
}
998
1013
hir:: StmtKind :: Expr ( ref expr) => {
999
1014
self . space_if_not_bol ( ) ?;
@@ -1562,30 +1577,6 @@ impl<'a> State<'a> {
1562
1577
Ok ( ( ) )
1563
1578
}
1564
1579
1565
- pub fn print_decl ( & mut self , decl : & hir:: Decl ) -> io:: Result < ( ) > {
1566
- self . maybe_print_comment ( decl. span . lo ( ) ) ?;
1567
- match decl. node {
1568
- hir:: DeclKind :: Local ( ref loc) => {
1569
- self . space_if_not_bol ( ) ?;
1570
- self . ibox ( indent_unit) ?;
1571
- self . word_nbsp ( "let" ) ?;
1572
-
1573
- self . ibox ( indent_unit) ?;
1574
- self . print_local_decl ( & loc) ?;
1575
- self . end ( ) ?;
1576
- if let Some ( ref init) = loc. init {
1577
- self . nbsp ( ) ?;
1578
- self . word_space ( "=" ) ?;
1579
- self . print_expr ( & init) ?;
1580
- }
1581
- self . end ( )
1582
- }
1583
- hir:: DeclKind :: Item ( item) => {
1584
- self . ann . nested ( self , Nested :: Item ( item) )
1585
- }
1586
- }
1587
- }
1588
-
1589
1580
pub fn print_usize ( & mut self , i : usize ) -> io:: Result < ( ) > {
1590
1581
self . s . word ( i. to_string ( ) )
1591
1582
}
@@ -2401,18 +2392,10 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
2401
2392
/// seen the semicolon, and thus don't need another.
2402
2393
fn stmt_ends_with_semi ( stmt : & hir:: StmtKind ) -> bool {
2403
2394
match * stmt {
2404
- hir:: StmtKind :: Decl ( ref d) => {
2405
- match d. node {
2406
- hir:: DeclKind :: Local ( _) => true ,
2407
- hir:: DeclKind :: Item ( _) => false ,
2408
- }
2409
- }
2410
- hir:: StmtKind :: Expr ( ref e) => {
2411
- expr_requires_semi_to_be_stmt ( & e)
2412
- }
2413
- hir:: StmtKind :: Semi ( ..) => {
2414
- false
2415
- }
2395
+ hir:: StmtKind :: Local ( _) => true ,
2396
+ hir:: StmtKind :: Item ( _) => false ,
2397
+ hir:: StmtKind :: Expr ( ref e) => expr_requires_semi_to_be_stmt ( & e) ,
2398
+ hir:: StmtKind :: Semi ( ..) => false ,
2416
2399
}
2417
2400
}
2418
2401
0 commit comments