Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 36e2cb0

Browse files
committed
add a section to the Contributing.md file about version-gating formatting changes
1 parent 3f6ea77 commit 36e2cb0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Contributing.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@ Please try to avoid leaving `TODO`s in the code. There are a few around, but I
9191
wish there weren't. You can leave `FIXME`s, preferably with an issue number.
9292

9393

94+
### Version-gate formatting changes
95+
96+
A change that introduces a different code-formatting should be gated on the
97+
`version` configuration. This is to ensure the formatting of the current major
98+
release is preserved, while allowing fixes to be implemented for the next
99+
release.
100+
101+
This is done by conditionally guarding the change like so:
102+
103+
```rust
104+
if config.version() == Version::One { // if the current major release is 1.x
105+
// current formatting
106+
} else {
107+
// new formatting
108+
}
109+
```
110+
111+
This allows the user to apply the next formatting explicitly via the
112+
configuration, while being stable by default.
113+
114+
When the next major release is done, the code block of the previous formatting
115+
can be deleted, e.g., the first block in the example above when going from `1.x`
116+
to `2.x`.
117+
118+
94119
### A quick tour of Rustfmt
95120

96121
Rustfmt is basically a pretty printer - that is, its mode of operation is to

0 commit comments

Comments
 (0)