diff --git a/src/expr.rs b/src/expr.rs index 9b59e0cbd78..de2166bddbe 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2895,7 +2895,7 @@ pub fn rewrite_assign_rhs>( let rhs = try_opt!(choose_rhs( context, ex, - shape, + orig_shape, ex.rewrite(context, orig_shape) )); Some(lhs + &rhs) @@ -2908,7 +2908,9 @@ fn choose_rhs( orig_rhs: Option, ) -> Option { match orig_rhs { - Some(ref new_str) if !new_str.contains('\n') => Some(format!(" {}", new_str)), + Some(ref new_str) if !new_str.contains('\n') && new_str.len() <= shape.width => { + Some(format!(" {}", new_str)) + } _ => { // Expression did not fit on the same line as the identifier. // Try splitting the line and see if that works better.