File tree 2 files changed +51
-0
lines changed
2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 47
47
- [ Cargo: Table and key name consistency] ( rust-2024/cargo-table-key-names.md )
48
48
- [ Cargo: Reject unused inherited default-features] ( rust-2024/cargo-inherited-default-features.md )
49
49
- [ Rustfmt: Combine all delimited exprs as last argument] ( rust-2024/rustfmt-overflow-delimited-expr.md )
50
+ - [ Rustfmt: Raw identifier sorting] ( rust-2024/rustfmt-raw-identifier-sorting.md )
50
51
- [ ` gen ` keyword] ( rust-2024/gen-keyword.md )
51
52
- [ Macro fragment specifiers] ( rust-2024/macro-fragment-specifiers.md )
52
53
- [ Missing macro fragment specifiers] ( rust-2024/missing-macro-fragment-specifiers.md )
Original file line number Diff line number Diff line change
1
+ # Rustfmt: Raw identifier sorting
2
+
3
+ 🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
4
+
5
+ More information may be found in the tracking issue at < https://github.com/rust-lang/rust/issues/124764 > .
6
+
7
+ ## Summary
8
+
9
+ ` rustfmt ` now properly sorts [ raw identifiers] .
10
+
11
+ [ raw identifiers ] : ../../reference/identifiers.html#raw-identifiers
12
+
13
+ ## Details
14
+
15
+ The [ Rust Style Guide] includes [ rules for sorting] [ sorting ] that ` rustfmt ` applies in various contexts, such as on imports.
16
+
17
+ 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:
18
+
19
+ ``` rust
20
+ use websocket :: client :: ClientBuilder ;
21
+ use websocket :: r#async :: futures :: Stream ;
22
+ use websocket :: result :: WebSocketError ;
23
+ ```
24
+
25
+ In the 2024 Edition, ` rustfmt ` now produces:
26
+
27
+ ``` rust
28
+ use websocket :: r#async :: futures :: Stream ;
29
+ use websocket :: client :: ClientBuilder ;
30
+ use websocket :: result :: WebSocketError ;
31
+ ```
32
+
33
+ [ Rust Style Guide ] : ../../style-guide/index.html
34
+ [ sorting ] : ../../style-guide/index.html#sorting
35
+
36
+ ## Migration
37
+
38
+ The change can be applied automatically by running ` cargo fmt ` or ` rustfmt ` with the 2024 Edition.
39
+
40
+ With a ` Cargo.toml ` file that has ` edition ` set to ` 2024 ` , run:
41
+
42
+ ``` sh
43
+ cargo fmt
44
+ ```
45
+
46
+ Or run ` rustfmt ` directly:
47
+
48
+ ``` sh
49
+ rustfmt foo.rs --style-edition 2024
50
+ ```
You can’t perform that action at this time.
0 commit comments