Skip to content

Commit e831877

Browse files
Revert "[style 2024] Combine all last arg delimited exprs"
This reverts commit bed0c9d.
1 parent 5a45ab9 commit e831877

File tree

2 files changed

+7
-52
lines changed

2 files changed

+7
-52
lines changed

Diff for: src/doc/style-guide/src/editions.md

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ For a full history of changes in the Rust 2024 style edition, see the git
3636
history of the style guide. Notable changes in the Rust 2024 style edition
3737
include:
3838

39-
- [#114764](https://github.com/rust-lang/rust/pull/114764) As the last member
40-
of a delimited expression, delimited expressions are generally combinable,
41-
regardless of the number of members. Previously only applied with exactly
42-
one member (except for closures with explicit blocks).
4339
- Miscellaneous `rustfmt` bugfixes.
4440
- Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order).
4541
- Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase".

Diff for: src/doc/style-guide/src/expressions.md

+7-48
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,11 @@ E.g., `&&Some(foo)` matches, `Foo(4, Bar)` does not.
818818

819819
## Combinable expressions
820820

821-
When the last argument in a function call is formatted across
822-
multiple-lines, format the outer call as if it were a single-line call,
821+
Where a function call has a single argument, and that argument is formatted
822+
across multiple-lines, format the outer call as if it were a single-line call,
823823
if the result fits. Apply the same combining behaviour to any similar
824824
expressions which have multi-line, block-indented lists of sub-expressions
825-
delimited by parentheses, brackets, or braces. E.g.,
825+
delimited by parentheses (e.g., macros or tuple struct literals). E.g.,
826826

827827
```rust
828828
foo(bar(
@@ -848,61 +848,20 @@ let arr = [combinable(
848848
an_expr,
849849
another_expr,
850850
)];
851-
852-
let x = Thing(an_expr, another_expr, match cond {
853-
A => 1,
854-
B => 2,
855-
});
856-
857-
let x = format!("Stuff: {}", [
858-
an_expr,
859-
another_expr,
860-
]);
861-
862-
let x = func(an_expr, another_expr, SomeStruct {
863-
field: this_is_long,
864-
another_field: 123,
865-
});
866851
```
867852

868853
Apply this behavior recursively.
869854

870-
If the last argument is a multi-line closure with an explicit block,
871-
only apply the combining behavior if there are no other closure arguments.
855+
For a function with multiple arguments, if the last argument is a multi-line
856+
closure with an explicit block, there are no other closure arguments, and all
857+
the arguments and the first line of the closure fit on the first line, use the
858+
same combining behavior:
872859

873860
```rust
874-
// Combinable
875861
foo(first_arg, x, |param| {
876862
action();
877863
foo(param)
878864
})
879-
// Not combinable, because the closure is not the last argument
880-
foo(
881-
first_arg,
882-
|param| {
883-
action();
884-
foo(param)
885-
},
886-
whatever,
887-
)
888-
// Not combinable, because the first line of the closure does not fit
889-
foo(
890-
first_arg,
891-
x,
892-
move |very_long_param_causing_line_to_overflow| -> Bar {
893-
action();
894-
foo(param)
895-
},
896-
)
897-
// Not combinable, because there is more than one closure argument
898-
foo(
899-
first_arg,
900-
|x| x.bar(),
901-
|param| {
902-
action();
903-
foo(param)
904-
},
905-
)
906865
```
907866

908867
## Ranges

0 commit comments

Comments
 (0)