@@ -992,23 +992,17 @@ impl<'a> State<'a> {
992992 match st. node {
993993 hir:: StmtKind :: Local ( ref loc) => {
994994 self . print_local ( loc. init . deref ( ) , |this| this. print_local_decl ( & loc) ) ?;
995+ self . s . word ( ";" ) ?;
995996 }
996997 hir:: StmtKind :: Item ( item) => {
997998 self . ann . nested ( self , Nested :: Item ( item) ) ?
998999 }
9991000 hir:: StmtKind :: Expr ( ref expr) => {
10001001 self . space_if_not_bol ( ) ?;
10011002 self . print_expr ( & expr) ?;
1002- }
1003- hir:: StmtKind :: Semi ( ref expr) => {
1004- self . space_if_not_bol ( ) ?;
1005- self . print_expr ( & expr) ?;
10061003 self . s . word ( ";" ) ?;
10071004 }
10081005 }
1009- if stmt_ends_with_semi ( & st. node ) {
1010- self . s . word ( ";" ) ?;
1011- }
10121006 self . maybe_print_trailing_comment ( st. span , None )
10131007 }
10141008
@@ -2325,36 +2319,6 @@ impl<'a> State<'a> {
23252319 }
23262320}
23272321
2328- // Dup'ed from parse::classify, but adapted for the HIR.
2329- /// Does this expression require a semicolon to be treated
2330- /// as a statement? The negation of this: 'can this expression
2331- /// be used as a statement without a semicolon' -- is used
2332- /// as an early-bail-out in the parser so that, for instance,
2333- /// if true {...} else {...}
2334- /// |x| 5
2335- /// isn't parsed as (if true {...} else {...} | x) | 5
2336- fn expr_requires_semi_to_be_stmt ( e : & hir:: Expr ) -> bool {
2337- match e. node {
2338- hir:: ExprKind :: Match ( ..) |
2339- hir:: ExprKind :: Block ( ..) |
2340- hir:: ExprKind :: While ( ..) |
2341- hir:: ExprKind :: Loop ( ..) => false ,
2342- _ => true ,
2343- }
2344- }
2345-
2346- /// this statement requires a semicolon after it.
2347- /// note that in one case (stmt_semi), we've already
2348- /// seen the semicolon, and thus don't need another.
2349- fn stmt_ends_with_semi ( stmt : & hir:: StmtKind ) -> bool {
2350- match * stmt {
2351- hir:: StmtKind :: Local ( _) => true ,
2352- hir:: StmtKind :: Item ( _) => false ,
2353- hir:: StmtKind :: Expr ( ref e) => expr_requires_semi_to_be_stmt ( & e) ,
2354- hir:: StmtKind :: Semi ( ..) => false ,
2355- }
2356- }
2357-
23582322fn bin_op_to_assoc_op ( op : hir:: BinOpKind ) -> AssocOp {
23592323 use crate :: hir:: BinOpKind :: * ;
23602324 match op {
0 commit comments