@@ -1273,9 +1273,11 @@ impl<'ast> State<'_, 'ast> {
1273
1273
&& call_args. len ( ) == 1
1274
1274
&& !with_single_call_chain_child
1275
1275
&& callee_fits;
1276
- let without_ind = !all_fits
1276
+ let without_ind = ( !all_fits
1277
1277
&& ( callee_fits || s. call_stack . first ( ) . is_some_and ( |c| c. is_chained ( ) ) )
1278
- && with_single_call_chain_child;
1278
+ && with_single_call_chain_child)
1279
+ // exception for when returning a binary expr that has a call in one of its members
1280
+ || s. return_bin_expr ;
1279
1281
1280
1282
s. print_call_args (
1281
1283
call_args,
@@ -1824,6 +1826,7 @@ impl<'ast> State<'_, 'ast> {
1824
1826
let fits_alone = space_left >= expr_size + 1 ;
1825
1827
1826
1828
if let Some ( expr) = expr {
1829
+ self . return_bin_expr = matches ! ( & expr. kind, ast:: ExprKind :: Binary ( ..) ) ;
1827
1830
let is_lit_or_ident =
1828
1831
matches ! ( & expr. kind, ast:: ExprKind :: Lit ( ..) | ast:: ExprKind :: Ident ( ..) ) ;
1829
1832
if is_lit_or_ident || ( overflows && fits_alone) {
@@ -1848,6 +1851,7 @@ impl<'ast> State<'_, 'ast> {
1848
1851
}
1849
1852
self . print_expr ( expr) ;
1850
1853
self . end ( ) ;
1854
+ self . return_bin_expr = false ;
1851
1855
} else {
1852
1856
self . print_word ( "return" ) ;
1853
1857
}
@@ -2616,6 +2620,17 @@ fn is_call_chain(expr_kind: &ast::ExprKind<'_>, must_have_child: bool) -> bool {
2616
2620
}
2617
2621
}
2618
2622
2623
+ fn is_call_chain_traverse_bin_ops ( expr_kind : & ast:: ExprKind < ' _ > , must_have_child : bool ) -> bool {
2624
+ match expr_kind {
2625
+ ast:: ExprKind :: Binary ( lhs, _, rhs) => {
2626
+ is_call_chain_traverse_bin_ops ( & lhs. kind , false )
2627
+ || is_call_chain_traverse_bin_ops ( & rhs. kind , false )
2628
+ }
2629
+ ast:: ExprKind :: Member ( child, ..) => is_call_chain_traverse_bin_ops ( & child. kind , false ) ,
2630
+ _ => !must_have_child && is_call ( expr_kind) ,
2631
+ }
2632
+ }
2633
+
2619
2634
#[ derive( Debug ) ]
2620
2635
struct Decision {
2621
2636
outcome : bool ,
0 commit comments