]> git.lizzy.rs Git - rust.git/commitdiff
Use rewrite() instead of format_expr
authortopecongiro <seuchida@gmail.com>
Sat, 2 Sep 2017 23:09:37 +0000 (08:09 +0900)
committertopecongiro <seuchida@gmail.com>
Sat, 2 Sep 2017 23:09:37 +0000 (08:09 +0900)
src/expr.rs
src/visitor.rs

index b65383311de9627188cb86fb1554ac73f8743933..228722474e1b8706d6aead24912a92b87367c41f 100644 (file)
@@ -876,13 +876,8 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                     ""
                 };
 
-                let expr_type = match self.node {
-                    ast::StmtKind::Expr(_) => ExprType::SubExpression,
-                    ast::StmtKind::Semi(_) => ExprType::Statement,
-                    _ => unreachable!(),
-                };
                 let shape = try_opt!(shape.sub_width(suffix.len()));
-                format_expr(ex, expr_type, context, shape).map(|s| s + suffix)
+                format_expr(ex, ExprType::Statement, context, shape).map(|s| s + suffix)
             }
             ast::StmtKind::Mac(..) | ast::StmtKind::Item(..) => None,
         };
index 56c1783476aa87ff0f237321abfbfd1b1bf3a798..a792148130b4a57af28e315c6cf78eaa4caff763 100644 (file)
@@ -22,7 +22,6 @@
               FindUncommented};
 use comment::rewrite_comment;
 use config::{BraceStyle, Config};
-use expr::{format_expr, ExprType};
 use items::{format_impl, format_trait, rewrite_associated_impl_type, rewrite_associated_type,
             rewrite_static, rewrite_type_alias};
 use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorPlace,
@@ -77,12 +76,7 @@ fn visit_stmt(&mut self, stmt: &ast::Stmt) {
                 let rewrite = stmt.rewrite(&self.get_context(), self.shape());
                 self.push_rewrite(stmt.span(), rewrite);
             }
-            ast::StmtKind::Expr(ref expr) => {
-                let rewrite =
-                    format_expr(expr, ExprType::Statement, &self.get_context(), self.shape());
-                self.push_rewrite(stmt.span(), rewrite)
-            }
-            ast::StmtKind::Semi(..) => {
+            ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
                 let rewrite = stmt.rewrite(&self.get_context(), self.shape());
                 self.push_rewrite(stmt.span(), rewrite)
             }