diff options
| author | Seiichi Uchida <seuchida@gmail.com> | 2018-12-25 18:20:29 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-25 18:20:29 +0900 |
| commit | 996d5e8d6ce2e756f50bfa51b9622c50f725415c (patch) | |
| tree | 375d0e17eec17fd12ff33bb3d8796c6473cb8936 /src/expr.rs | |
| parent | 09c9cd41256c8232274534189a0dffde2656f447 (diff) | |
Fix shape when formatting return or break expr on statement position (#3259)
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/expr.rs b/src/expr.rs index 9509f0f4980..0d8e9c87580 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -41,7 +41,7 @@ use types::{rewrite_path, PathContext}; use utils::{ colon_spaces, contains_skip, count_newlines, first_line_ends_with, inner_attributes, last_line_extendable, last_line_width, mk_sp, outer_attributes, ptr_vec_to_ref_vec, - semicolon_for_stmt, wrap_str, + semicolon_for_expr, semicolon_for_stmt, wrap_str, }; use vertical::rewrite_with_alignment; use visitor::FmtVisitor; @@ -69,6 +69,11 @@ pub fn format_expr( if contains_skip(&*expr.attrs) { return Some(context.snippet(expr.span()).to_owned()); } + let shape = if expr_type == ExprType::Statement && semicolon_for_expr(context, expr) { + shape.sub_width(1)? + } else { + shape + }; let expr_rw = match expr.node { ast::ExprKind::Array(ref expr_vec) => rewrite_array( |
