Skip to content

Commit

Permalink
Revert "Rollup merge of rust-lang#132369 - joshtriplett:style-guide-b…
Browse files Browse the repository at this point in the history
…inop-heuristic-assignment-only, r=calebcartwright"

This reverts commit 348d280, reversing
changes made to 526c67f.
  • Loading branch information
ehuss committed Dec 31, 2024
1 parent 3bf62cc commit a6ba04a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/doc/style-guide/src/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ include:
of a delimited expression, delimited expressions are generally combinable,
regardless of the number of members. Previously only applied with exactly
one member (except for closures with explicit blocks).
- When line-breaking an assignment operator, if the left-hand side spans
multiple lines, use the base indentation of the last line of the left-hand
side to indent the right-hand side.
- When line-breaking a binary operator, if the first operand spans multiple
lines, use the base indentation of the last line.
- Miscellaneous `rustfmt` bugfixes.
- Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order).
- Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase".
Expand Down
12 changes: 9 additions & 3 deletions src/doc/style-guide/src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ foo_bar
Prefer line-breaking at an assignment operator (either `=` or `+=`, etc.) rather
than at other binary operators.

If line-breaking an assignment operator where the left-hand side spans multiple
lines, use the base indentation of the *last* line of the left-hand side, and
indent the right-hand side relative to that:
If line-breaking at a binary operator (including assignment operators) where the
first operand spans multiple lines, use the base indentation of the *last*
line of the first operand, and indent relative to that:

```rust
impl SomeType {
Expand All @@ -341,6 +341,12 @@ impl SomeType {
.extra_info =
long_long_long_long_long_long_long_long_long_long_long_long_long_long_long;

self.array[array_index as usize]
.as_mut()
.expect("thing must exist")
.extra_info
+ long_long_long_long_long_long_long_long_long_long_long_long_long_long_long;

self.array[array_index as usize]
.as_mut()
.expect("thing must exist")
Expand Down

0 comments on commit a6ba04a

Please sign in to comment.