@@ -31,10 +31,9 @@ use patterns::{can_be_overflowed_pat, TuplePatField};
31
31
use rewrite:: { Rewrite , RewriteContext } ;
32
32
use string:: { rewrite_string, StringFormat } ;
33
33
use types:: { can_be_overflowed_type, rewrite_path, PathContext } ;
34
- use utils:: { binary_search, colon_spaces, contains_skip, extra_offset, first_line_width,
35
- inner_attributes, last_line_extendable, last_line_width, left_most_sub_expr, mk_sp,
36
- outer_attributes, paren_overhead, semicolon_for_stmt, stmt_expr,
37
- trimmed_last_line_width, wrap_str} ;
34
+ use utils:: { colon_spaces, contains_skip, extra_offset, first_line_width, inner_attributes,
35
+ last_line_extendable, last_line_width, left_most_sub_expr, mk_sp, outer_attributes,
36
+ paren_overhead, semicolon_for_stmt, stmt_expr, trimmed_last_line_width, wrap_str} ;
38
37
use vertical:: rewrite_with_alignment;
39
38
use visitor:: FmtVisitor ;
40
39
@@ -82,13 +81,8 @@ pub fn format_expr(
82
81
} ,
83
82
ast:: ExprKind :: Call ( ref callee, ref args) => {
84
83
let inner_span = mk_sp ( callee. span . hi ( ) , expr. span . hi ( ) ) ;
85
- rewrite_call_with_binary_search (
86
- context,
87
- & * * callee,
88
- & args. iter ( ) . map ( |x| & * * x) . collect :: < Vec < _ > > ( ) [ ..] ,
89
- inner_span,
90
- shape,
91
- )
84
+ let callee_str = try_opt ! ( callee. rewrite( context, shape) ) ;
85
+ rewrite_call ( context, & callee_str, & args, inner_span, shape)
92
86
}
93
87
ast:: ExprKind :: Paren ( ref subexpr) => rewrite_paren ( context, subexpr, shape) ,
94
88
ast:: ExprKind :: Binary ( ref op, ref lhs, ref rhs) => {
@@ -1982,46 +1976,6 @@ fn string_requires_rewrite(
1982
1976
false
1983
1977
}
1984
1978
1985
- pub fn rewrite_call_with_binary_search < R > (
1986
- context : & RewriteContext ,
1987
- callee : & R ,
1988
- args : & [ & ast:: Expr ] ,
1989
- span : Span ,
1990
- shape : Shape ,
1991
- ) -> Option < String >
1992
- where
1993
- R : Rewrite ,
1994
- {
1995
- let force_trailing_comma = if context. inside_macro {
1996
- span_ends_with_comma ( context, span)
1997
- } else {
1998
- false
1999
- } ;
2000
- let closure = |callee_max_width| {
2001
- // FIXME using byte lens instead of char lens (and probably all over the
2002
- // place too)
2003
- let callee_shape = Shape {
2004
- width : callee_max_width,
2005
- ..shape
2006
- } ;
2007
- let callee_str = callee
2008
- . rewrite ( context, callee_shape)
2009
- . ok_or ( Ordering :: Greater ) ?;
2010
-
2011
- rewrite_call_inner (
2012
- context,
2013
- & callee_str,
2014
- args,
2015
- span,
2016
- shape,
2017
- context. config . fn_call_width ( ) ,
2018
- force_trailing_comma,
2019
- )
2020
- } ;
2021
-
2022
- binary_search ( 1 , shape. width , closure)
2023
- }
2024
-
2025
1979
pub fn rewrite_call (
2026
1980
context : & RewriteContext ,
2027
1981
callee : & str ,
0 commit comments