Skip to content

Commit 0242643

Browse files
authored
Rollup merge of rust-lang#113394 - joshtriplett:style-edition-snapshot, r=calebcartwright
style-guide: Document style editions, start 2024 style edition Link to a snapshot for the 2015/2018/2021 style edition. This is a draft, because I'd like to wait for a few style guide fixes to merge before snapshotting the 2015/2018/2021 style edition: - rust-lang#113145 - rust-lang#113380 - rust-lang#113384 - rust-lang#113385 - rust-lang#113386 - rust-lang#113392 I'd like to wait for these for two reasons: to make it easier to see the differences between the 2015/2018/2021 style edition and the 2024 style edition (without the noise of guide-wide changes), and to minimize confusion so that bugfixes to the style guide that we include in the previous edition don't look like they're only part of the 2024 style edition. I've used "Miscellaneous `rustfmt` bugfixes" as a starting point for the list of 2024 changes, for now. We can update that when we add more 2024 changes. The section added in this PR can then serve as a baseline for our drafts of 2024 style edition changes. In the meantime, I'd like to get someone from `@rust-lang/style` to review and approve the text here; I'll update it with a commit hash when the above PRs have merged.
2 parents 14a5dc5 + 6a0886c commit 0242643

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/doc/style-guide/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
- [Other style advice](advice.md)
1010
- [`Cargo.toml` conventions](cargo.md)
1111
- [Guiding principles and rationale](principles.md)
12+
- [Rust style editions](editions.md)
1213
- [Nightly-only syntax](nightly.md)

src/doc/style-guide/src/editions.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Rust style editions
2+
3+
The default Rust style evolves over time, as Rust does. However, to avoid
4+
breaking established code style, and CI jobs checking code style, changes to
5+
the default Rust style only appear in *style editions*.
6+
7+
Code written in a given
8+
[Rust edition](https://doc.rust-lang.org/edition-guide/)
9+
uses the corresponding Rust style edition by default. To make it easier to
10+
migrate code style separately from the semantic changes between Rust editions,
11+
formatting tools such as `rustfmt` allow updating the style edition separately
12+
from the Rust edition.
13+
14+
The current version of the style guide describes the latest Rust style edition.
15+
Each distinct past style will have a corresponding archived version of the
16+
style guide.
17+
18+
Note that archived versions of the style guide do not document formatting for
19+
newer Rust constructs that did not exist at the time that version of the style
20+
guide was archived. However, each style edition will still format all
21+
constructs valid in that Rust edition, with the style of newer constructs
22+
coming from the first subsequent style edition providing formatting rules for
23+
that construct (without any of the systematic/global changes from that style
24+
edition).
25+
26+
Not all Rust editions have corresponding changes to the Rust style. For
27+
instance, Rust 2015, Rust 2018, and Rust 2021 all use the same style edition.
28+
29+
## Rust 2024 style edition
30+
31+
This style guide describes the Rust 2024 style edition. The Rust 2024 style
32+
edition is currently nightly-only and may change before the release of Rust
33+
2024.
34+
35+
For a full history of changes in the Rust 2024 style edition, see the git
36+
history of the style guide. Notable changes in the Rust 2024 style edition
37+
include:
38+
39+
- Miscellaneous `rustfmt` bugfixes.
40+
41+
## Rust 2015/2018/2021 style edition
42+
43+
The archived version of the style guide at
44+
<https://github.com/rust-lang/rust/tree/37343f4a4d4ed7ad0891cb79e8eb25acf43fb821/src/doc/style-guide/src>
45+
describes the style edition corresponding to Rust 2015, Rust 2018, and Rust
46+
2021.

0 commit comments

Comments
 (0)