From 8b64b529749d3c96d2714fcc33e34e74f3bb79d4 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 19 Oct 2024 19:32:11 +0000 Subject: [PATCH] Prepare PR #321 to be merged We needed to add an entry to the ToC, and we made various editorial tweaks. --- src/SUMMARY.md | 1 + ...s.md => rustfmt-raw-identifier-sorting.md} | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) rename src/rust-2024/{rustfmt-raw-identifiers.md => rustfmt-raw-identifier-sorting.md} (57%) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 437fee4a..1179717b 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -48,6 +48,7 @@ - [Cargo: Table and key name consistency](rust-2024/cargo-table-key-names.md) - [Cargo: Reject unused inherited default-features](rust-2024/cargo-inherited-default-features.md) - [Rustfmt: Combine all delimited exprs as last argument](rust-2024/rustfmt-overflow-delimited-expr.md) + - [Rustfmt: Raw identifier sorting](rust-2024/rustfmt-raw-identifier-sorting.md) - [`gen` keyword](rust-2024/gen-keyword.md) - [Macro fragment specifiers](rust-2024/macro-fragment-specifiers.md) - [Missing macro fragment specifiers](rust-2024/missing-macro-fragment-specifiers.md) diff --git a/src/rust-2024/rustfmt-raw-identifiers.md b/src/rust-2024/rustfmt-raw-identifier-sorting.md similarity index 57% rename from src/rust-2024/rustfmt-raw-identifiers.md rename to src/rust-2024/rustfmt-raw-identifier-sorting.md index f2df9ece..1c12401d 100644 --- a/src/rust-2024/rustfmt-raw-identifiers.md +++ b/src/rust-2024/rustfmt-raw-identifier-sorting.md @@ -1,22 +1,20 @@ -# Rustfmt: raw identifier sorting +# Rustfmt: Raw identifier sorting 🚧 The 2024 Edition has not yet been released and hence this section is still "under construction". -More information may be found in . +More information may be found in the tracking issue at . ## Summary `rustfmt` now properly sorts [raw identifiers]. -[raw identifiers]: https://doc.rust-lang.org/rust-by-example/compatibility/raw_identifiers.html +[raw identifiers]: ../../reference/identifiers.html#raw-identifiers ## Details The [Rust Style Guide] includes [rules for sorting][sorting] that `rustfmt` applies in various contexts, such as on imports. -Prior to the 2024 Edition, when sorting rustfmt would use the leading `r#` token instead of the ident which led to specious results. - -For example: +Prior to the 2024 Edition, when sorting rustfmt would use the leading `r#` token instead of the ident which led to unwanted results. For example: ```rust use websocket::client::ClientBuilder; @@ -24,7 +22,7 @@ use websocket::r#async::futures::Stream; use websocket::result::WebSocketError; ``` -Which is now corrected in the 2024 Edition: +In the 2024 Edition, `rustfmt` now produces: ```rust use websocket::r#async::futures::Stream; @@ -32,20 +30,20 @@ use websocket::client::ClientBuilder; use websocket::result::WebSocketError; ``` -[Rust Style Guide]: https://doc.rust-lang.org/nightly/style-guide/index.html -[sorting]: https://doc.rust-lang.org/stable/style-guide/index.html?highlight=sort#sorting +[Rust Style Guide]: ../../style-guide/index.html +[sorting]: ../../style-guide/index.html#sorting ## Migration The change can be applied automatically by running `cargo fmt` or `rustfmt` with the 2024 Edition. -With a Cargo.toml file that has `edition` set to `2024`: +With a `Cargo.toml` file that has `edition` set to `2024`, run: ```sh cargo fmt ``` -Or by running `rustfmt` directly: +Or run `rustfmt` directly: ```sh rustfmt foo.rs --style-edition 2024