@@ -109,17 +109,17 @@ If you want to test modified `cargo-fmt`, or run `rustfmt` on the whole project
109
109
RUSTFMT="./target/debug/rustfmt" cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
110
110
```
111
111
112
- ### Version-gate formatting changes
112
+ ### Gate formatting changes
113
113
114
- A change that introduces a different code-formatting should be gated on the
115
- ` version ` configuration. This is to ensure the formatting of the current major
116
- release is preserved, while allowing fixes to be implemented for the next
117
- release.
114
+ A change that introduces a different code-formatting must be gated on the
115
+ ` style_edition ` configuration. This is to ensure rustfmt upholds its formatting
116
+ stability guarantees and adheres to the Style Edition process set in [ RFC 3338]
118
117
119
- This is done by conditionally guarding the change like so :
118
+ This can be done by conditionally guarding the formatting change, e.g. :
120
119
121
120
``` rust
122
- if config . version () == Version :: One { // if the current major release is 1.x
121
+ // if the current stable Style Edition is Edition 2024
122
+ if config . style_edition () <= StyleEdition :: Edition2024 {
123
123
// current formatting
124
124
} else {
125
125
// new formatting
@@ -129,13 +129,14 @@ if config.version() == Version::One { // if the current major release is 1.x
129
129
This allows the user to apply the next formatting explicitly via the
130
130
configuration, while being stable by default.
131
131
132
- When the next major release is done, the code block of the previous formatting
133
- can be deleted, e.g., the first block in the example above when going from ` 1.x `
134
- to ` 2.x ` .
132
+ This can then be enhanced as needed if and when there are
133
+ new Style Editions with differing formatting prescriptions.
135
134
136
135
| Note: Only formatting changes with default options need to be gated. |
137
136
| --- |
138
137
138
+ [ RFC 3338 ] : https://rust-lang.github.io/rfcs/3338-style-evolution.html
139
+
139
140
### A quick tour of Rustfmt
140
141
141
142
Rustfmt is basically a pretty printer - that is, its mode of operation is to
0 commit comments