From f885039e6c2ba75bf50127d4e8e15bc79b772119 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sun, 6 May 2018 12:12:16 +0900 Subject: [PATCH] Do not overflow a long item Take the first line's width of a single item into account when trying to overflow something. Closes #2676. --- src/overflow.rs | 2 +- tests/source/expr.rs | 7 +++++++ tests/target/expr.rs | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/overflow.rs b/src/overflow.rs index b42c6be90caf..96bebc50bfd3 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -422,7 +422,7 @@ impl<'a, T: 'a + Rewrite + ToExpr + Spanned> Context<'a, T> { let extend_width = if items_str.is_empty() { paren_overhead } else { - paren_overhead / 2 + first_line_width(items_str) + (paren_overhead / 2) }; let nested_indent_str = self.nested_shape .indent diff --git a/tests/source/expr.rs b/tests/source/expr.rs index 91e8e300b984..5c7c02a4b824 100644 --- a/tests/source/expr.rs +++ b/tests/source/expr.rs @@ -391,3 +391,10 @@ fn dots() { ..= ..= ..; (..) .. ..; // ((..) .. (..)) } + +// #2676 +// A function call with a large single argument. +fn foo() { + let my_var = + Mutex::new(RpcClientType::connect(server_iddd).chain_err(|| "Unable to create RPC client")?); +} diff --git a/tests/target/expr.rs b/tests/target/expr.rs index 977c7f2331b6..50387731d14f 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -416,3 +416,11 @@ fn dots() { ..= ..= ..; (..).. ..; // ((..) .. (..)) } + +// #2676 +// A function call with a large single argument. +fn foo() { + let my_var = Mutex::new( + RpcClientType::connect(server_iddd).chain_err(|| "Unable to create RPC client")? + ); +}