about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2024-01-10 19:21:27 -0800
committerJosh Triplett <josh@joshtriplett.org>2024-05-13 16:43:13 +0200
commit9ff777bf50cb26107496c1bfdd178c56c5a57cca (patch)
tree9a8d2bcc7f40c4076505102f09dc048d78218c4e
parent2af29af710aa4613e4ff670e5902d7ea6725988f (diff)
downloadrust-9ff777bf50cb26107496c1bfdd178c56c5a57cca.tar.gz
rust-9ff777bf50cb26107496c1bfdd178c56c5a57cca.zip
style-guide: Also format where clauses on one line for short function decls
-rw-r--r--src/doc/style-guide/src/items.md20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md
index 095e5512ea9..9b8cdaed88b 100644
--- a/src/doc/style-guide/src/items.md
+++ b/src/doc/style-guide/src/items.md
@@ -295,8 +295,18 @@ Prefer to use single-letter names for generic parameters.
 
 These rules apply for `where` clauses on any item.
 
-If immediately following a closing bracket of any kind, write the keyword
-`where` on the same line, with a space before it.
+If a where clause is short, and appears on a short one-line function
+declaration with no body or a short associated 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.
 
 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
@@ -424,9 +434,9 @@ bound, put a space after the colon but not before:
 type Foo: Bar;
 ```
 
-If an associated type 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:
+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;