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

Revert #119515 single line where clause style guide #134974

Merged
merged 1 commit into from
Jan 1, 2025
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
1 change: 0 additions & 1 deletion src/doc/style-guide/src/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ include:
- 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".
- Format single associated type `where` clauses on the same line if they fit.

## Rust 2015/2018/2021 style edition

Expand Down
30 changes: 4 additions & 26 deletions src/doc/style-guide/src/items.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,8 @@ Prefer to use single-letter names for generic parameters.

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

If a where clause is short, and appears on a short one-line function
declaration with no body or on a short type with no `=`, format it on
the same line as the declaration:

```rust
fn new(&self) -> Self where Self: Sized;

type Item<'a>: SomeTrait where Self: 'a;
```

Otherwise, if immediately following a closing bracket of any kind, write the
keyword `where` on the same line, with a space before it.
If immediately following a closing bracket of any kind, write the keyword
`where` on the same line, with a space before it.

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

If a `where` clause is very short, prefer using an inline bound on the type
parameter if possible.
parameter.

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

```rust
type Foo: Bar;
pub type Foo: Bar;
```

If an associated type is short, has no `=`, and has a `where` clause with only
one entry, format the entire type declaration including the `where` clause on
the same line if it fits:

```rust
type Item<'a> where Self: 'a;
type Item<'a>: PartialEq + Send where Self: 'a;
```

If the associated type has a `=`, or if the `where` clause contains multiple
entries, format it across multiple lines as with a type alias.

## extern items

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