Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style-guide: Only use the new binop heuristic for assignments #132369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/doc/style-guide/src/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ 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 a binary operator, if the first operand spans multiple
lines, use the base indentation of the last line.
- 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.
- 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: 3 additions & 9 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 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:
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:

```rust
impl SomeType {
Expand All @@ -341,12 +341,6 @@ 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;

joshtriplett marked this conversation as resolved.
Show resolved Hide resolved
self.array[array_index as usize]
.as_mut()
.expect("thing must exist")
Expand Down
Loading