@@ -70,8 +70,8 @@ use crate::rewrite::{Rewrite, RewriteContext};
7070use crate :: shape:: Shape ;
7171use crate :: source_map:: SpanUtils ;
7272use crate :: utils:: {
73- self , first_line_width, last_line_extendable, last_line_width, mk_sp, rewrite_ident ,
74- trimmed_last_line_width, wrap_str,
73+ self , filtered_str_fits , first_line_width, last_line_extendable, last_line_width, mk_sp,
74+ rewrite_ident , trimmed_last_line_width, wrap_str,
7575} ;
7676
7777pub ( crate ) fn rewrite_chain (
@@ -810,15 +810,14 @@ impl<'a> ChainFormatter for ChainFormatterVisual<'a> {
810810 . visual_indent ( self . offset )
811811 . sub_width ( self . offset ) ?;
812812 let rewrite = item. rewrite ( context, child_shape) ?;
813- match wrap_str ( rewrite, context. config . max_width ( ) , shape) {
814- Some ( rewrite) => root_rewrite. push_str ( & rewrite) ,
815- None => {
816- // We couldn't fit in at the visual indent, try the last
817- // indent.
818- let rewrite = item. rewrite ( context, parent_shape) ?;
819- root_rewrite. push_str ( & rewrite) ;
820- self . offset = 0 ;
821- }
813+ if filtered_str_fits ( & rewrite, context. config . max_width ( ) , shape) {
814+ root_rewrite. push_str ( & rewrite) ;
815+ } else {
816+ // We couldn't fit in at the visual indent, try the last
817+ // indent.
818+ let rewrite = item. rewrite ( context, parent_shape) ?;
819+ root_rewrite. push_str ( & rewrite) ;
820+ self . offset = 0 ;
822821 }
823822
824823 self . shared . children = & self . shared . children [ 1 ..] ;
0 commit comments