diff options
| author | bors <bors@rust-lang.org> | 2024-05-14 14:40:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-14 14:40:20 +0000 |
| commit | ac385a5af6d9fa8399a0cec799833cd28324abf8 (patch) | |
| tree | c66b9db6d2e2804081cac4f0928ae299ac13d790 /src/doc | |
| parent | bdfd941f4dcbe54e0283433ac970febf4092fa6a (diff) | |
| parent | 31016d587936da143456bac5c9a89bcad8236bd3 (diff) | |
| download | rust-ac385a5af6d9fa8399a0cec799833cd28324abf8.tar.gz rust-ac385a5af6d9fa8399a0cec799833cd28324abf8.zip | |
Auto merge of #125120 - compiler-errors:rollup-mnjybwv, r=compiler-errors
Rollup of 7 pull requests Successful merges: - #119838 (style-guide: When breaking binops handle multi-line first operand better) - #124844 (Use a proper probe for shadowing impl) - #125047 (Migrate `run-make/issue-14500` to new `rmake.rs` format) - #125080 (only find segs chain for missing methods when no available candidates) - #125088 (Uplift `AliasTy` and `AliasTerm`) - #125100 (Don't do post-method-probe error reporting steps if we're in a suggestion) - #125118 (Use new utility functions/methods in run-make tests) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/style-guide/src/editions.md | 2 | ||||
| -rw-r--r-- | src/doc/style-guide/src/expressions.md | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/doc/style-guide/src/editions.md b/src/doc/style-guide/src/editions.md index 9d593f80810..74e873e35ff 100644 --- a/src/doc/style-guide/src/editions.md +++ b/src/doc/style-guide/src/editions.md @@ -40,6 +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 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". diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 171a24cd89d..3bb0ee6d5ff 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -328,6 +328,37 @@ 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: + +```rust +impl SomeType { + fn method(&mut self) { + 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") + .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 = Some(ExtraInfo { + parent, + count: count as u16, + children: children.into_boxed_slice(), + }); + } +} +``` + ### Casts (`as`) Format `as` casts like a binary operator. In particular, always include spaces |
