@@ -1814,6 +1814,9 @@ where
1814
1814
} ;
1815
1815
let used_width = extra_offset ( callee_str, shape) ;
1816
1816
let one_line_width = shape. width . checked_sub ( used_width + 2 * paren_overhead) ?;
1817
+ // 1 = "("
1818
+ let combine_arg_with_callee =
1819
+ callee_str. len ( ) + 1 <= context. config . tab_spaces ( ) && args. len ( ) == 1 ;
1817
1820
1818
1821
// 1 = "(" or ")"
1819
1822
let one_line_shape = shape
@@ -1838,6 +1841,7 @@ where
1838
1841
one_line_width,
1839
1842
args_max_width,
1840
1843
force_trailing_comma,
1844
+ combine_arg_with_callee,
1841
1845
) ?;
1842
1846
1843
1847
if !context. use_block_indent ( ) && need_block_indent ( & list_str, nested_shape) && !extendable {
@@ -1878,6 +1882,7 @@ fn rewrite_call_args<'a, T>(
1878
1882
one_line_width : usize ,
1879
1883
args_max_width : usize ,
1880
1884
force_trailing_comma : bool ,
1885
+ combine_arg_with_callee : bool ,
1881
1886
) -> Option < ( bool , String ) >
1882
1887
where
1883
1888
T : Rewrite + Spanned + ToExpr + ' a ,
@@ -1907,6 +1912,7 @@ where
1907
1912
nested_shape,
1908
1913
one_line_width,
1909
1914
args_max_width,
1915
+ combine_arg_with_callee,
1910
1916
) ;
1911
1917
1912
1918
let fmt = ListFormatting {
@@ -1937,19 +1943,22 @@ fn try_overflow_last_arg<'a, T>(
1937
1943
nested_shape : Shape ,
1938
1944
one_line_width : usize ,
1939
1945
args_max_width : usize ,
1946
+ combine_arg_with_callee : bool ,
1940
1947
) -> DefinitiveListTactic
1941
1948
where
1942
1949
T : Rewrite + Spanned + ToExpr + ' a ,
1943
1950
{
1944
- let overflow_last = can_be_overflowed ( context, args) ;
1951
+ let overflow_last = combine_arg_with_callee || can_be_overflowed ( context, args) ;
1945
1952
1946
1953
// Replace the last item with its first line to see if it fits with
1947
1954
// first arguments.
1948
1955
let placeholder = if overflow_last {
1949
1956
let mut context = context. clone ( ) ;
1950
- if let Some ( expr) = args[ args. len ( ) - 1 ] . to_expr ( ) {
1951
- if let ast:: ExprKind :: MethodCall ( ..) = expr. node {
1952
- context. force_one_line_chain = true ;
1957
+ if !combine_arg_with_callee {
1958
+ if let Some ( expr) = args[ args. len ( ) - 1 ] . to_expr ( ) {
1959
+ if let ast:: ExprKind :: MethodCall ( ..) = expr. node {
1960
+ context. force_one_line_chain = true ;
1961
+ }
1953
1962
}
1954
1963
}
1955
1964
last_arg_shape ( args, item_vec, one_line_shape, args_max_width) . and_then ( |arg_shape| {
0 commit comments