@@ -801,11 +801,11 @@ E.g., `&&Some(foo)` matches, `Foo(4, Bar)` does not.
801801
802802## Combinable expressions
803803
804- Where a function call has a single argument, and that argument is formatted
805- across multiple-lines, format the outer call as if it were a single-line call,
804+ When the last argument in a function call is formatted across
805+ multiple-lines, format the outer call as if it were a single-line call,
806806if the result fits. Apply the same combining behaviour to any similar
807807expressions which have multi-line, block-indented lists of sub-expressions
808- delimited by parentheses (e.g., macros or tuple struct literals) . E.g.,
808+ delimited by parentheses, brackets, or braces . E.g.,
809809
810810``` rust
811811foo (bar (
@@ -831,20 +831,61 @@ let arr = [combinable(
831831 an_expr ,
832832 another_expr ,
833833)];
834+
835+ let x = Thing (an_expr , another_expr , match cond {
836+ A => 1 ,
837+ B => 2 ,
838+ });
839+
840+ let x = format! (" Stuff: {}" , [
841+ an_expr ,
842+ another_expr ,
843+ ]);
844+
845+ let x = func (an_expr , another_expr , SomeStruct {
846+ field : this_is_long ,
847+ another_field : 123 ,
848+ });
834849```
835850
836851Apply this behavior recursively.
837852
838- For a function with multiple arguments, if the last argument is a multi-line
839- closure with an explicit block, there are no other closure arguments, and all
840- the arguments and the first line of the closure fit on the first line, use the
841- same combining behavior:
853+ If the last argument is a multi-line closure with an explicit block,
854+ only apply the combining behavior if there are no other closure arguments.
842855
843856``` rust
857+ // Combinable
844858foo (first_arg , x , | param | {
845859 action ();
846860 foo (param )
847861})
862+ // Not combinable, because the closure is not the last argument
863+ foo (
864+ first_arg ,
865+ | param | {
866+ action ();
867+ foo (param )
868+ },
869+ whatever ,
870+ )
871+ // Not combinable, because the first line of the closure does not fit
872+ foo (
873+ first_arg ,
874+ x ,
875+ move | very_long_param_causing_line_to_overflow | -> Bar {
876+ action ();
877+ foo (param )
878+ },
879+ )
880+ // Not combinable, because there is more than one closure argument
881+ foo (
882+ first_arg ,
883+ | x | x . bar (),
884+ | param | {
885+ action ();
886+ foo (param )
887+ },
888+ )
848889```
849890
850891## Ranges
0 commit comments