Skip to content

Commit fee79a2

Browse files
authored
Rollup merge of #134974 - ehuss:revert-single-line-where, r=compiler-errors
Revert #119515 single line where clause style guide This did not get implemented for the style edition in 2024, so this PR removes it from the documentation. See tracking issue #132381. This can be added back in the next edition if it gets implemented. I'm a little unclear on what the style team intends for how future changes are documented. For example, the current style-guide documented behavior that rustfmt does not support. I'm not sure who the audience for this document is, or how this is intended to stay in sync with rustfmt. For example, if I read this and assume this is how it is supposed to work, and then rustfmt breaks that, it seems like that is confusing. Similarly, if I'm staying on an older edition, this documentation would be incorrect for my crate. Perhaps changes like this could be "teed-up" in a PR, but not merged until the edition is stabilized (similar to how the reference works)? And include notes for parts that are edition-specific (so if I am using an older edition, I can see that something is different). In general, I'm a little confused on how this is intended to work. Reverts: - #119515
2 parents 8a2979c + b4a0926 commit fee79a2

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ include:
4646
- Miscellaneous `rustfmt` bugfixes.
4747
- Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order).
4848
- Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase".
49-
- Format single associated type `where` clauses on the same line if they fit.
5049

5150
## Rust 2015/2018/2021 style edition
5251

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

+4-26
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,8 @@ Prefer to use single-letter names for generic parameters.
295295

296296
These rules apply for `where` clauses on any item.
297297

298-
If a where clause is short, and appears on a short one-line function
299-
declaration with no body or on a short type with no `=`, format it on
300-
the same line as the declaration:
301-
302-
```rust
303-
fn new(&self) -> Self where Self: Sized;
304-
305-
type Item<'a>: SomeTrait where Self: 'a;
306-
```
307-
308-
Otherwise, if immediately following a closing bracket of any kind, write the
309-
keyword `where` on the same line, with a space before it.
298+
If immediately following a closing bracket of any kind, write the keyword
299+
`where` on the same line, with a space before it.
310300

311301
Otherwise, put `where` on a new line at the same indentation level. Put each
312302
component of a `where` clause on its own line, block-indented. Use a trailing
@@ -357,7 +347,7 @@ where
357347
```
358348

359349
If a `where` clause is very short, prefer using an inline bound on the type
360-
parameter if possible.
350+
parameter.
361351

362352
If a component of a `where` clause does not fit and contains `+`, break it
363353
before each `+` and block-indent the continuation lines. Put each bound on its
@@ -431,21 +421,9 @@ Format associated types like type aliases. Where an associated type has a
431421
bound, put a space after the colon but not before:
432422

433423
```rust
434-
type Foo: Bar;
424+
pub type Foo: Bar;
435425
```
436426

437-
If an associated type is short, has no `=`, and has a `where` clause with only
438-
one entry, format the entire type declaration including the `where` clause on
439-
the same line if it fits:
440-
441-
```rust
442-
type Item<'a> where Self: 'a;
443-
type Item<'a>: PartialEq + Send where Self: 'a;
444-
```
445-
446-
If the associated type has a `=`, or if the `where` clause contains multiple
447-
entries, format it across multiple lines as with a type alias.
448-
449427
## extern items
450428

451429
When writing extern items (such as `extern "C" fn`), always specify the ABI.

0 commit comments

Comments
 (0)