]> git.lizzy.rs Git - rust.git/blobdiff - src/chains.rs
rewrite_string: retain blank lines that are trailing
[rust.git] / src / chains.rs
index 36c89eef20dbd9d2f2e64e4a43105b0ddb71643a..b7619c0a18af49a65bee7bc253211cad1d9817fe 100644 (file)
@@ -576,7 +576,15 @@ fn format_last_child(
         if all_in_one_line || extendable {
             // First we try to 'overflow' the last child and see if it looks better than using
             // vertical layout.
-            if let Some(one_line_shape) = last_shape.offset_left(almost_total) {
+            let one_line_shape = if context.use_block_indent() {
+                last_shape.offset_left(almost_total)
+            } else {
+                last_shape
+                    .visual_indent(almost_total)
+                    .sub_width(almost_total)
+            };
+
+            if let Some(one_line_shape) = one_line_shape {
                 if let Some(rw) = last.rewrite(context, one_line_shape) {
                     // We allow overflowing here only if both of the following conditions match:
                     // 1. The entire chain fits in a single line except the last child.
@@ -844,6 +852,7 @@ fn is_block_expr(context: &RewriteContext, expr: &ast::Expr, repr: &str) -> bool
         ast::ExprKind::Mac(..)
         | ast::ExprKind::Call(..)
         | ast::ExprKind::MethodCall(..)
+        | ast::ExprKind::Array(..)
         | ast::ExprKind::Struct(..)
         | ast::ExprKind::While(..)
         | ast::ExprKind::WhileLet(..)