@@ -992,8 +992,23 @@ impl<'a> State<'a> {
992992 pub fn print_stmt ( & mut self , st : & hir:: Stmt ) -> io:: Result < ( ) > {
993993 self . maybe_print_comment ( st. span . lo ( ) ) ?;
994994 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) ) ?
9971012 }
9981013 hir:: StmtKind :: Expr ( ref expr) => {
9991014 self . space_if_not_bol ( ) ?;
@@ -1562,30 +1577,6 @@ impl<'a> State<'a> {
15621577 Ok ( ( ) )
15631578 }
15641579
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-
15891580 pub fn print_usize ( & mut self , i : usize ) -> io:: Result < ( ) > {
15901581 self . s . word ( i. to_string ( ) )
15911582 }
@@ -2401,18 +2392,10 @@ fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
24012392/// seen the semicolon, and thus don't need another.
24022393fn stmt_ends_with_semi ( stmt : & hir:: StmtKind ) -> bool {
24032394 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 ,
24162399 }
24172400}
24182401
0 commit comments