Skip to content

Commit c5dc1fd

Browse files
committed
apply various edits from the PR thread
1 parent 545832c commit c5dc1fd

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

text/0000-edition-2021.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Key points include:
1313
* Editions are used to introduce changes into the language that would otherwise have the potential to break existing code, such as the introduction of a new keyword.
1414
* Editions are never allowed to split the ecosystem. We only permit changes that still allow crates in different editions to interoperate.
1515
* Editions are named after the year in which they occur (e.g., Rust 2015, Rust 2018, Rust 2021).
16-
* When we release a new edition, we also release tooling to automate the migration of crates. Some manual work may be required but that should be the rare case.
16+
* When we release a new edition, we also release tooling to automate the migration of crates. Some manual work may be required but that should be uncommon.
1717
* The nightly toolchain offers "preview" access to upcoming editions, so that we can land work that targets future editions at any time.
1818
* We maintain an Edition Migration Guide that offers guidance on how to migrate to the next edition.
1919
* Whenever possible, new features should be made to work across all editions.
@@ -25,26 +25,26 @@ This RFC is meant to establish the high-level purpose of an edition and to descr
2525
# Motivation
2626
[motivation]: #motivation
2727

28-
The plan for editions was laid out in [RFC 2052] and Rust had its first edition in 2018. This effort was in many ways a success but also resulted in some difficult lessons. This RFC proposes a different model for the 2021 Edition. Depending on our experience, we may opt to continue with this model in the future, or we may wish to make changes for future editions.
28+
The plan for editions was laid out in [RFC 2052] and Rust had its first edition in 2018. This effort was in many ways a success but also resulted in a lot of stress on the Rust organization as a whole. This RFC proposes a different model for the 2021 Edition. Depending on our experience, we may opt to continue with this model in the future, or we may wish to make changes for future editions.
2929

3030
## Editions enable "stability without stagnation"
3131

3232
The release of Rust 1.0 established ["stability without stagnation"](https://blog.rust-lang.org/2014/10/30/Stability.html) as a core Rust deliverable. Ever since the 1.0 release, the rule for Rust has been that once a feature has been released on stable, we are committed to supporting that feature for all future releases.
3333

3434
There are times, however, when it is useful to be able to make small changes in the surface syntax of Rust that would not otherwise be backwards compatible. The most obvious example is introducing a new keyword, which would invalidate existing names for variables and so forth. Even when such changes do not "feel" backwards incompatible, they still have the potential to break existing code. If we were to make such changes, people would quickly find that existing programs stopped compiling.
3535

36-
**Editions** are the mechanism we use to square this circle. When we wish to release a feature that would otherwise be backwards incompatible, we do so as part of a new **Rust edition**. Editions are opt-in, and so existing crates do not see these changes until they explicitly migrate over to the new edition.
36+
**Editions** are the mechanism we use to square this circle. When we wish to release a feature that would otherwise be backwards incompatible, we do so as part of a new **Rust edition**. Editions are opt-in, and so existing crates do not see these changes until they explicitly migrate over to the new edition. New creates created by cargo always default to the most recent edition.
3737

3838
# Guide-level explanation
3939
[guide-level-explanation]: #guide-level-explanation
4040

41-
The follow sections define the goals and design principles that we will use for the 2021 edition, and potentially for future editions. The ordering is significant, with earlier sections taking precedence in the case of a conflict. (For example, it's more important that users are able to control when they adopt the new edition than it is for the edition to be rapidly adopted.)
41+
The following sections define the goals and design principles that we will use for the 2021 edition, and potentially for future editions. The ordering is significant, with earlier sections taking precedence in the case of a conflict. (For example, it's more important that users are able to control when they adopt the new edition than it is for the edition to be rapidly adopted.)
4242

4343
## Editions do not split the ecosystem
4444

4545
The most important rule for editions is that crates in one edition can interoperate seamlessly with crates compiled in other editions. This ensures that the decision to migrate to a newer edition is a "private one" that the crate can make without affecting others, apart from the fact that it affects the version of rustc that is required, akin to making use of any new feature.
4646

47-
The requirement for crate interoperability implies some limits on the kinds of changes that we can make in an edition. In general, changes that occur in a edition tend to be "skin deep". All Rust code, regardless of edition, is ultimately compiled to the same internal IR within the compiler.
47+
The requirement for crate interoperability implies some limits on the kinds of changes that we can make in an edition. In general, changes that occur in an edition tend to be "skin deep". All Rust code, regardless of edition, is ultimately compiled to the same internal representation within the compiler.
4848

4949
## Edition migration is easy and largely automated
5050

@@ -85,27 +85,31 @@ This RFC explicitly does not attempt to specify the cadence for releasing editio
8585

8686
There are various constraints on the timing of editions that have been identified over time:
8787

88-
* Even if it's automated, migrating to a new edition can require a significant investment of time, particularly for production users with many crates. We don't wish to release Editions at a rate that makes it hard for such users to keep up.
88+
* Even if it's automated, migrating to a new edition can require a significant investment of time, particularly for production users with many crates. We don't wish to release editions at a rate that makes it hard for such users to keep up.
8989
* At the same time, we don't wish to wait too long in between editions. We want to maintain the spirit of Rust's train model, so that folks don't feel a "rush" to get work done by any particular deadline.
9090
* Having a generally known time when editions will be released is helpful in planning feature development.
9191
* We do not wish to release an empty edition. Sometimes there simply won't be any backwards incompatible changes and thus no reason to issue an edition.
9292

9393
## Definition: migration
9494

95-
**Migrations** are the "breaking changes" introduced by the edition, except of course that since editions are opt-in, no code actually breaks.
95+
**Migrations** are the "breaking changes" introduced by the edition; of course, since editions are opt-in, existing code does not actually break.
9696

9797
## Definition: migration lint
9898

9999
Migrations typically come with one or more **migration lints**. Each lint warns about code that will need to change in order to move to the new edition. The lints typically contain "suggestions", which is a diff that can be applied to make the code work in the new edition. In some cases, the rewrite may be too complex for the lint to make a suggestion. In addition, some suggestions are marked as "not machine applicable", if they are not known to be semantics preserving.
100100

101+
## Default edition for new projects
102+
103+
The default edition for new projects will be 2021.
104+
101105
## Tooling workflow
102106

103107
The expected workflow for upgrading to a new edition is as follows:
104108

105109
* **Prepare to upgrade:** Run `cargo fix --edition`: This will automatically prepare your code to be upgraded to next edition by applying any suggestions from the migration lints.
106110
* For example, if your code is in Rust 2018, this will prepare you to move to the 2021 edition.
107111
* Note that `cargo fix` does not actually move your code to the new edition. Instead, it produces code that works in both the old and the new edition.
108-
* This allows people to upgrade and fix things in a "piecemeal" fashion. Because of this, however, the code produces by these suggestions is not always the most idiomatic, as it is not able to take advantage of features from the new edition.
112+
* This allows people to upgrade and fix things in a "piecemeal" fashion. Because of this, however, the code produced by these suggestions is not always the most idiomatic, as it is not able to take advantage of features from the new edition.
109113
* The expectation is that `cargo fix` should be able to fix the majority of crates out there, but it is not required that the tooling is able to handle every case. As long as code does not occur frequently in the wild, it is acceptable for the automated suggestions to be inapplicable to edge cases. The metrics section in this RFC includes some guidelines for how to measure this.
110114
* **Upgrade:** Edit your cargo.toml to include `edition = "2021"` instead of the older edition.
111115
* The code should still build, but it may be necessary to make some fixes or other changes.
@@ -122,7 +126,7 @@ Some examples of changes the editions can make:
122126
* Introducing a new keyword, as with `async-await`.
123127
* This change comes with automated tooling that rewrites identifiers using that keyword to use `r#` form.
124128
* Changing closures so that they capture precise paths, rather than entire variables, as in [RFC 2229].
125-
* This change comes with automated tooling that modifies closures to capture
129+
* This change comes with automated tooling that modifies closures to capture entire variables when necessary.
126130
* In MIR, closures are desugared into structs with fields, so all editions can still target the same internal representation.
127131
* Changing the prelude for Rust code.
128132
* Changing type inference rules.
@@ -172,7 +176,7 @@ The following metrics are an attempt to quantify some of the goals we have for e
172176
# Drawbacks
173177
[drawbacks]: #drawbacks
174178

175-
Executing an edition requires coordination. There has also been some concern that Rust is making too many changes and moving too quickly, and releasing a new edition could feed those narratives. On the other hand, the fact that this edition is relatively limited in scope and that it will be marketed less aggressively also helps here. Further, continuing the regular cadence for editions has its own advantages, and helps us to make some changes (such as closure capture or format printing) that are very valuable.
179+
Executing an edition requires coordination. There has also been some concern that Rust is making too many changes and moving too quickly, and releasing a new edition could feed those fears. On the other hand, the fact that this edition is relatively limited in scope and that it will be marketed less aggressively also helps here. Further, continuing the regular cadence for editions has its own advantages, and helps us to make some changes (such as closure capture or format printing) that are very valuable.
176180

177181
# Rationale and alternatives
178182
[rationale-and-alternatives]: #rationale-and-alternatives

0 commit comments

Comments
 (0)