From 85254c9dd8266f24658071b773fbc3ba2da7b35c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 16 Aug 2023 16:40:12 +0000 Subject: bugfix: reflect how rustfmt formats type aliases --- src/doc/style-guide/src/items.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/doc') diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md index a6d941f6d04..b93f2fbde4d 100644 --- a/src/doc/style-guide/src/items.md +++ b/src/doc/style-guide/src/items.md @@ -367,14 +367,14 @@ where ## Type aliases Keep type aliases on one line when they fit. If necessary to break the line, do -so after the `=`, and block-indent the right-hand side: +so before the `=`, and block-indent the right-hand side: ```rust pub type Foo = Bar; // If multi-line is required -type VeryLongType = - AnEvenLongerType>; +type VeryLongType + = AnEvenLongerType>; ``` Where possible avoid `where` clauses and keep type constraints inline. Where -- cgit 1.4.1-3-g733a5 From f707b9cd707d84768687caa025d483cef61ed440 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 16 Aug 2023 16:41:49 +0000 Subject: Describe how to format trailing where clauses --- src/doc/style-guide/src/items.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/doc') diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md index b93f2fbde4d..dc10f4ff15d 100644 --- a/src/doc/style-guide/src/items.md +++ b/src/doc/style-guide/src/items.md @@ -378,15 +378,38 @@ type VeryLongType ``` Where possible avoid `where` clauses and keep type constraints inline. Where -that is not possible split the line before and after the `where` clause (and -split the `where` clause as normal), e.g., +that is not possible, prefer a trailing `where` clause over one that precedes +the type. Split the line before and after a trailing `where` clause (and split +the `where` clause as normal) and indent before the `=` and type, e.g., ```rust type VeryLongType + = AnEvenLongerType> +where + T: U::AnAssociatedType, + U: SomeBound; +``` + +When there is a `where` clause before the type, format it normally, and break +after the last clause. Do not indent before the `=` to leave it visually +distinct from the indented clauses. + +``` +type WithPrecedingWC where T: U::AnAssociatedType, U: SomeBound, = AnEvenLongerType>; + +// Or with both a preceding and trailing where clause. +type WithPrecedingWC +where + T: U::AnAssociatedType, + U: SomeBound, += AnEvenLongerType> +where + T: U::AnAssociatedType2, + U: SomeBound2; ``` ## Associated types -- cgit 1.4.1-3-g733a5 From 2ff14b0050145b79769bf207b7d0bee5c98292b8 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 23 Aug 2023 18:25:09 +0000 Subject: Remove opinions from style guide about where clauses in type alias items --- src/doc/style-guide/src/items.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/doc') diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md index dc10f4ff15d..b215de6ad28 100644 --- a/src/doc/style-guide/src/items.md +++ b/src/doc/style-guide/src/items.md @@ -377,12 +377,12 @@ type VeryLongType = AnEvenLongerType>; ``` -Where possible avoid `where` clauses and keep type constraints inline. Where -that is not possible, prefer a trailing `where` clause over one that precedes -the type. Split the line before and after a trailing `where` clause (and split -the `where` clause as normal) and indent before the `=` and type, e.g., +When there is a trailing `where` clause after the type, and no `where` clause +present before the type, break before the `=` and indent. Then break before the +`where` keyword and format the clauses normally, e.g., ```rust +// With only a trailing where clause type VeryLongType = AnEvenLongerType> where @@ -392,9 +392,12 @@ where When there is a `where` clause before the type, format it normally, and break after the last clause. Do not indent before the `=` to leave it visually -distinct from the indented clauses. +distinct from the indented clauses that precede it. If there is additionally a +`where` clause after the type, break before the `where` keyword and format the +clauses normally. -``` +```rust +// With only a preceding where clause. type WithPrecedingWC where T: U::AnAssociatedType, -- cgit 1.4.1-3-g733a5 From 08c4963a32a4a9e9d9ce4d76e53a7d4bb85b1711 Mon Sep 17 00:00:00 2001 From: Emmanuel Ferdman Date: Wed, 27 Sep 2023 18:30:33 +0300 Subject: Update location of personality --- src/doc/unstable-book/src/language-features/lang-items.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/doc') diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index 9e20662fff3..32b882e763d 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -37,7 +37,7 @@ Most lang items are defined by `core`, but if you're trying to build an executable without the `std` crate, you might run into the need for lang item definitions. -[personality]: https://github.com/rust-lang/rust/blob/master/library/std/src/personality/gcc.rs +[personality]: https://github.com/rust-lang/rust/blob/master/library/std/src/sys/personality/gcc.rs ## Example: Implementing a `Box` -- cgit 1.4.1-3-g733a5