From 24cb82bbce5c6d505935f7e72a8416ec2988f915 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 9 Dec 2024 08:48:23 -0800 Subject: [PATCH] Revert "2024: Add chapter on single-line `where` clauses" --- src/SUMMARY.md | 1 - .../rustfmt-single-line-where-clauses.md | 43 ------------------- 2 files changed, 44 deletions(-) delete mode 100644 src/rust-2024/rustfmt-single-line-where-clauses.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 20b49997..49219796 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -68,6 +68,5 @@ - [Rustfmt: Style edition](rust-2024/rustfmt-style-edition.md) - [Rustfmt: Assignment operator RHS indentation](rust-2024/rustfmt-assignment-operator-rhs-indentation.md) - [Rustfmt: Combine all delimited exprs as last argument](rust-2024/rustfmt-overflow-delimited-expr.md) - - [Rustfmt: Single-line `where` clauses](rust-2024/rustfmt-single-line-where-clauses.md) - [Rustfmt: Raw identifier sorting](rust-2024/rustfmt-raw-identifier-sorting.md) - [Rustfmt: Version sorting](rust-2024/rustfmt-version-sorting.md) diff --git a/src/rust-2024/rustfmt-single-line-where-clauses.md b/src/rust-2024/rustfmt-single-line-where-clauses.md deleted file mode 100644 index 71ae158b..00000000 --- a/src/rust-2024/rustfmt-single-line-where-clauses.md +++ /dev/null @@ -1,43 +0,0 @@ -# Rustfmt: Single-line where clauses - -## Summary - -When an associated type or method declaration has a single bound in the `where` clause, it can now sometimes be formatted on one line. - -## Details - -In general, the [Rust Style Guide](../../style-guide/index.html) states to wrap `where` clauses onto subsequent lines, with the keyword `where` on a line of its own and then the individual clauses indented on subsequent lines. - -However, in the 2024 Edition, when writing an associated type declaration or a method declaration (with no body), a short `where` clause can appear on the same line. - -This is particularly useful for generic associated types (GATs), which often need `Self: Sized` bounds. - -In Rust 2021 and before, this would look like: - -```rust -trait MyTrait { - fn new(&self) -> Self - where - Self: Sized; - - type Item<'a>: Send - where - Self: 'a; -} -``` - -In the 2024 Edition, `rustfmt` now produces: - -```rust -trait MyTrait { - fn new(&self) -> Self where Self: Sized; - - type Item<'a>: Send where Self: 'a; -} -``` - -## Migration - -The change can be applied automatically by running `cargo fmt` or `rustfmt` with the 2024 Edition. See the [Style edition] chapter for more information on migrating and how style editions work. - -[Style edition]: rustfmt-style-edition.md