diff --git a/src/chains.rs b/src/chains.rs index 0181cd3d099..9dabf2d0322 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -195,12 +195,19 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) - if fits_single_line { fits_single_line = match expr.node { ref e @ ast::ExprKind::MethodCall(..) => { - rewrite_method_call_with_overflow(e, - &mut last[0], - almost_total, - total_span, - context, - shape) + if rewrite_method_call_with_overflow(e, + &mut last[0], + almost_total, + total_span, + context, + shape) { + // If the first line of the last method does not fit into a single line + // after the others, allow new lines. + let first_line = try_opt!(last[0].lines().nth(0)); + almost_total + first_line.len() < context.config.max_width + } else { + false + } } _ => !last[0].contains('\n'), }