From 35c75d793854171e5494fc7ea81b6d856b065336 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 9 Dec 2024 08:47:41 -0800 Subject: [PATCH] Revert "2024: Assignment operator RHS indentation" --- src/SUMMARY.md | 1 - ...fmt-assignment-operator-rhs-indentation.md | 59 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 src/rust-2024/rustfmt-assignment-operator-rhs-indentation.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 20b49997..0a5da996 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -66,7 +66,6 @@ - [Rustdoc nested `include!` change](rust-2024/rustdoc-nested-includes.md) - [Rustfmt](rust-2024/rustfmt.md) - [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) diff --git a/src/rust-2024/rustfmt-assignment-operator-rhs-indentation.md b/src/rust-2024/rustfmt-assignment-operator-rhs-indentation.md deleted file mode 100644 index 3f800923..00000000 --- a/src/rust-2024/rustfmt-assignment-operator-rhs-indentation.md +++ /dev/null @@ -1,59 +0,0 @@ -# Rustfmt: Assignment operator RHS indentation - -## Summary - -In the 2024 Edition, `rustfmt` now indents the right-hand side of an assignment operator relative to the last line of the left-hand side, providing a clearer delineation and making it easier to notice the assignment operator. - -## Details - -In Rust 2021 and before, if an assignment operator has a multi-line left-hand side, the indentation of the right-hand side will visually run together with the left-hand side: - -```rust,ignore -impl SomeType { - fn method(&mut self) { - self.array[array_index as usize] - .as_mut() - .expect("thing must exist") - .extra_info = - long_long_long_long_long_long_long_long_long_long_long_long_long_long_long; - - self.array[array_index as usize] - .as_mut() - .expect("thing must exist") - .extra_info = Some(ExtraInfo { - parent, - count: count as u16, - children: children.into_boxed_slice(), - }); - } -} -``` - -In the 2024 Edition, `rustfmt` now indents the right-hand side relative to the last line of the left-hand side: - -```rust,ignore -impl SomeType { - fn method(&mut self) { - self.array[array_index as usize] - .as_mut() - .expect("thing must exist") - .extra_info = - long_long_long_long_long_long_long_long_long_long_long_long_long_long_long; - - self.array[array_index as usize] - .as_mut() - .expect("thing must exist") - .extra_info = Some(ExtraInfo { - parent, - count: count as u16, - children: children.into_boxed_slice(), - }); - } -} -``` - -## 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