From 6b8f62fcc8467d4cf694727ef8fde8aefda264bc Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 26 Jul 2017 17:42:52 +0900 Subject: [PATCH] Avoid regression --- src/expr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 99208b921340..7cebf793c600 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2281,10 +2281,10 @@ fn rewrite_last_closure( let body_shape = try_opt!(shape.offset_left(extra_offset)); // When overflowing the closure which consists of a single control flow expression, // force to use block if its condition uses multi line. - if rewrite_cond(context, body, body_shape) - .map(|cond| cond.contains('\n')) - .unwrap_or(false) - { + let is_multi_lined_cond = rewrite_cond(context, body, body_shape) + .map(|cond| cond.contains('\n') || cond.len() > body_shape.width) + .unwrap_or(false); + if is_multi_lined_cond { return rewrite_closure_with_block(context, body_shape, &prefix, body); }