@@ -8,7 +8,7 @@ use crate::rewrite::{Rewrite, RewriteContext};
8
8
use crate :: shape:: Shape ;
9
9
use crate :: source_map:: LineRangeUtils ;
10
10
use crate :: spanned:: Spanned ;
11
- use crate :: utils:: semicolon_for_stmt;
11
+ use crate :: utils:: { semicolon_for_expr , semicolon_for_stmt} ;
12
12
13
13
pub ( crate ) struct Stmt < ' a > {
14
14
inner : & ' a ast:: Stmt ,
@@ -116,7 +116,7 @@ fn format_stmt(
116
116
117
117
let result = match stmt. kind {
118
118
ast:: StmtKind :: Local ( ref local) => local. rewrite ( context, shape) ,
119
- ast:: StmtKind :: Expr ( ref ex ) | ast :: StmtKind :: Semi ( ref ex) => {
119
+ ast:: StmtKind :: Semi ( ref ex) => {
120
120
let suffix = if semicolon_for_stmt ( context, stmt, is_last_expr) {
121
121
";"
122
122
} else {
@@ -126,6 +126,16 @@ fn format_stmt(
126
126
let shape = shape. sub_width ( suffix. len ( ) ) ?;
127
127
format_expr ( ex, expr_type, context, shape) . map ( |s| s + suffix)
128
128
}
129
+ ast:: StmtKind :: Expr ( ref ex) => {
130
+ let suffix = if semicolon_for_expr ( context, ex) {
131
+ ";"
132
+ } else {
133
+ ""
134
+ } ;
135
+
136
+ let shape = shape. sub_width ( suffix. len ( ) ) ?;
137
+ format_expr ( ex, expr_type, context, shape) . map ( |s| s + suffix)
138
+ }
129
139
ast:: StmtKind :: MacCall ( ..) | ast:: StmtKind :: Item ( ..) | ast:: StmtKind :: Empty => None ,
130
140
} ;
131
141
result. and_then ( |res| recover_comment_removed ( res, stmt. span ( ) , context) )
0 commit comments