Skip to content

Commit 6a5510c

Browse files
committed
Revise the stabilization process changes
This PR contains a number of changes to better describe our stabilization process and policies. Let's revise this a bit, editorially, to better describe some of the nuances in our process, and to capture some additional details we want people to speak to in their stabilization reports and consider when reviewing stabilization PRs.
1 parent 7847bb8 commit 6a5510c

File tree

3 files changed

+182
-114
lines changed

3 files changed

+182
-114
lines changed

src/implementing_new_features.md

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ When you want to implement a new significant feature in the compiler,
66
you need to go through this process to make sure everything goes
77
smoothly.
88

9-
**NOTE: this section is for *language* features, not *library* features,
9+
**NOTE: This section is for *language* features, not *library* features,
1010
which use [a different process].**
1111

1212
See also [the Rust Language Design Team's procedures][lang-propose] for
@@ -92,32 +92,37 @@ make the necessary changes, and are satisfied, we expose it to
9292
the world using the stabilization process described [here].
9393
Until then, the feature is not set in stone: every part of the
9494
feature can be changed, or the feature might be completely
95-
rewritten or removed. Features are not supposed to gain tenure
96-
by being unstable and unchanged for a year.
95+
rewritten or removed. Features do not gain tenure by being
96+
unstable and unchanged for long periods of time.
9797

9898
### Tracking Issues
9999

100-
To keep track of the status of an unstable feature, the
101-
experience we get while using it on nightly, and of the
102-
concerns that block its stabilization, every feature-gate
103-
needs a tracking issue. General discussions about the feature should be done on the tracking issue.
100+
To keep track of the status of an unstable feature, the experience we get while using it on
101+
nightly, and of the concerns that block its stabilization, every feature-gate needs a tracking
102+
issue. When creating issues and PRs related to the feature, reference this tracking issue, and when there are updates about the feature's progress, post those to the tracking issue.
104103

105-
For features that have an RFC, you should use the RFC's
106-
tracking issue for the feature.
104+
For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that.
107105

108-
For other features, you'll have to make a tracking issue
109-
for that feature. The issue title should be "Tracking issue
110-
for YOUR FEATURE". Use the ["Tracking Issue" issue template][template].
106+
For other features, create a tracking issue for that feature. The issue title should be "Tracking
107+
issue for YOUR FEATURE". Use the ["Tracking Issue" issue template][template].
111108

112109
[template]: https://github.com/rust-lang/rust/issues/new?template=tracking_issue.md
113110

111+
### Lang experiments
112+
113+
To land in the compiler, features that have user-visible effects on the language (even unstable ones) must either be part of an accepted RFC or an approved [lang experiment].
114+
115+
To propose a new lang experiment, open an issue in `rust-lang/rust` that describes the motivation and the intended solution. If it's accepted, this issue will become the tracking issue for the experiment, so use the tracking issue [template] while also including these other details. Nominate the issue for the lang team and CC `@rust-lang/lang`. When the experiment is approved, the tracking issue will be marked as `B-experimental`.
116+
117+
Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature.
118+
119+
[lang experiment]: https://lang-team.rust-lang.org/how_to/experiment.html
120+
114121
## Stability in code
115122

116-
The below steps needs to be followed in order to implement
117-
a new unstable feature:
123+
The below steps needs to be followed in order to implement a new unstable feature:
118124

119-
1. Open a [tracking issue] -
120-
if you have an RFC, you can use the tracking issue for the RFC.
125+
1. Open or identify the [tracking issue]. For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that.
121126

122127
The tracking issue should be labeled with at least `C-tracking-issue`.
123128
For a language feature, a label `F-feature_name` should be added as well.
@@ -160,6 +165,8 @@ a new unstable feature:
160165
(incomplete, deref_patterns, "CURRENT_RUSTC_VERSION", Some(87121), None),
161166
```
162167

168+
Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature.
169+
163170
To avoid [semantic merge conflicts], please use `CURRENT_RUSTC_VERSION` instead of `1.70` or
164171
another explicit version number.
165172

@@ -176,16 +183,16 @@ a new unstable feature:
176183

177184
For features introducing new syntax, pre-expansion gating should be used instead.
178185
During parsing, when the new syntax is parsed, the symbol must be inserted to the
179-
current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`.
180-
181-
After being inserted to the gated spans, the span must be checked in the
186+
current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`.
187+
188+
After being inserted to the gated spans, the span must be checked in the
182189
[`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies
183-
features. Exactly how it is gated depends on the exact type of feature, but most
184-
likely will use the `gate_all!()` macro.
190+
features. Exactly how it is gated depends on the exact type of feature, but most
191+
likely will use the `gate_all!()` macro.
185192

186193
1. Add a test to ensure the feature cannot be used without
187194
a feature gate, by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`.
188-
You can generate the corresponding `.stderr` file by running `./x test
195+
You can generate the corresponding `.stderr` file by running `./x test
189196
tests/ui/feature-gates/ --bless`.
190197

191198
1. Add a section to the unstable book, in
@@ -209,33 +216,33 @@ tests/ui/feature-gates/ --bless`.
209216

210217
## Call for testing
211218

212-
Once the implementation is complete, the feature will be available to nightly users, but not yet part of stable Rust. This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a **Call for Testing**.
219+
Once the implementation is complete, the feature will be available to nightly users but not yet part of stable Rust. This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a "call for testing".
213220

214-
Some example Call for Testing blog posts:
221+
Some earlier such blog posts include:
215222

216223
1. [The push for GATs stabilization](https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push/)
217224
2. [Changes to `impl Trait` in Rust 2024](https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html)
218225
3. [Async Closures MVP: Call for Testing!](https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing/)
219226

220-
Alternatively, [*This Week in Rust*][twir] has a [call-for-testing section][twir-cft]. Example:
227+
Alternatively, [*This Week in Rust*][twir] has a [section][twir-cft] for this. One example of this having been used is:
221228

222-
- [Call for testing on boolean literals as cfg predicates](https://github.com/rust-lang/rust/issues/131204#issuecomment-2569314526).
229+
- [Call for testing on boolean literals as cfg predicates](https://github.com/rust-lang/rust/issues/131204#issuecomment-2569314526)
223230

224-
Which option to choose might depend on how significant the language change is, though note that [*This Week in Rust*][twir]'s Call for Testing section might be less visible than a dedicated post on the main Rust blog.
231+
Which option to choose might depend on how significant the language change is, though note that the [*This Week in Rust*][twir] section might be less visible than a dedicated post on the main Rust blog.
225232

226-
## Affiliated work
233+
## Polishing
227234

228-
Once the feature is supported by rustc, there is other associated work that needs to be done to give users a complete experience. Think of it as the *language toolchain* developer experience, which doesn't only comprise of the language or compiler in isolation.
235+
Giving users a polished experience means more than just implementing the feature in rustc. We need to think about all of the tools and resources that we ship. This work includes:
229236

230237
- Documenting the language feature in the [Rust Reference][reference].
231-
- (If applicable) Extending [`rustfmt`] to format any new syntax.
232-
- (If applicable) Extending [`rust-analyzer`]. This can depend on the nature of the language feature, as some features don't need to be blocked on *full* support.
233-
- A blocking concern is when a language feature degrades the user experience simply by existing before its support is implemented in [`rust-analyzer`].
234-
- Example blocking concern: new syntax that [`rust-analyzer`] can't parse -> bogus diagnostics, type inference changes -> bogus diagnostics.
238+
- Extending [`rustfmt`] to format any new syntax (if applicable).
239+
- Extending [`rust-analyzer`] (if applicable). The extent of this work can depend on the nature of the language feature, as some features don't need to be blocked on *full* support.
240+
- When a language feature degrades the user experience simply by existing before support is implemented in [`rust-analyzer`], that may lead the lang team to raise a blocking concern.
241+
- Examples of such might include new syntax that [`rust-analyzer`] can't parse or type inference changes it doesn't understand when those lead to bogus diagnostics.
235242

236243
## Stabilization
237244

238-
The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. At this point, backwards incompatible changes are no longer permitted (modulo soundness bugs and inference changes; see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for full details). To learn more about stabilization, see the [stabilization guide][stab].
245+
The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. At this point, backward incompatible changes are generally no longer permitted (see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for details). To learn more about stabilization, see the [stabilization guide][stab].
239246

240247

241248
[stab]: ./stabilization_guide.md

src/stabilization_guide.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Request for stabilization
22

3-
**NOTE**: this page is about stabilizing *language* features.
4-
For stabilizing *library* features, see [Stabilizing a library feature].
3+
**NOTE**: This page is about stabilizing *language* features. For stabilizing *library* features, see [Stabilizing a library feature].
54

65
[Stabilizing a library feature]: ./stability.md#stabilizing-a-library-feature
76

8-
Once an unstable feature has been well-tested with no outstanding
9-
concern, anyone may push for its stabilization. It involves the
10-
following steps:
7+
Once an unstable feature has been well-tested with no outstanding concerns, anyone may push for its stabilization. It involves the following steps:
118

129
<!-- toc -->
1310

11+
## Write an RFC, if needed
12+
13+
If the feature was part of a [lang experiment], the lang team must first accept an RFC for the feature before it can be stabilized.
14+
15+
[lang experiment]: https://lang-team.rust-lang.org/how_to/experiment.html
16+
1417
## Documentation PRs
1518

1619
<a id="updating-documentation"></a>
@@ -26,14 +29,9 @@ If there wasn't documentation there, it needs to be added.
2629

2730
Places that may need updated documentation:
2831

29-
- [The Reference]: This must be updated, in full detail.
30-
- [The Book]: This may or may not need updating, depends.
31-
If you're not sure, please open an issue on this repository
32-
and it can be discussed.
33-
- standard library documentation: As needed. Language features
34-
often don't need this, but if it's a feature that changes
35-
how good examples are written, such as when `?` was added
36-
to the language, updating examples is important.
32+
- [The Reference]: This must be updated, in full detail, and a member of the lang-docs team must review and approve the PR before the stabilization can be merged.
33+
- [The Book]: This may or may not need updating; it depends. If you're not sure, please open an issue on this repository and it can be discussed.
34+
- Standard library documentation: As needed. Language features often don't need this, but if it's a feature that changes how idiomatic examples are written, such as when `?` was added to the language, updating these in the library documentation is important.
3735
- [Rust by Example]: As needed.
3836

3937
Prepare PRs to update documentation involving this new feature
@@ -45,29 +43,23 @@ has completed. Meanwhile, we can proceed to the next step.
4543

4644
Author a stabilization report using the [template found in this repository][srt].
4745

48-
Stabilization reports summarize:
46+
The stabilization reports summarizes:
4947

50-
- The main design decisions and deviations since the RFC was accepted, particularly decisions that were FCP'd or otherwise accepted by the language team.
51-
- Quite often, the final stabilized language feature can have significant design deviations from the original RFC text.
48+
- The main design decisions and deviations since the RFC was accepted, including both decisions that were FCP'd or otherwise accepted by the language team as well as those being presented to the lang team for the first time.
49+
- Often, the final stabilized language feature has significant design deviations from the original RFC. That's OK, but these deviations must be highlighted and explained carefully.
5250
- The work that has been done since the RFC was accepted, acknowledging the main contributors that helped drive the language feature forward.
5351

54-
The [*Stabilization Template*][srt] includes a series of questions that aim to surface interconnections between this feature and the various Rust teams (lang, types, etc) and also to identify items that are commonly overlooked.
52+
The [*Stabilization Template*][srt] includes a series of questions that aim to surface connections between this feature and lang's subteams (e.g. types, opsem, lang-docs, etc.) and to identify items that are commonly overlooked.
5553

5654
[srt]: ./stabilization_report_template.md
5755

5856
The stabilization report is typically posted as the main comment on the stabilization PR (see the next section).
5957

6058
## Stabilization PR for a language feature
6159

62-
*This is for stabilizing language features. If you are stabilizing a library
63-
feature, see [the stabilization chapter of the std dev guide][std-guide-stabilization] instead.*
60+
Every feature is different, and some may require steps beyond what this guide discusses.
6461

65-
Here is a general guide to how to stabilize a feature --
66-
every feature is different, of course, so some features may
67-
require steps beyond what this guide talks about.
68-
69-
Note: Before we stabilize any feature, it's the rule that it
70-
should appear in the documentation.
62+
Before the stabilization will be considered by the lang team, there must be a complete PR to the Reference describing the feature, and before the stabilization PR will be merged, this PR must have been reviewed and approved by the lang-docs team.
7163

7264
### Updating the feature-gate listing
7365

@@ -94,11 +86,11 @@ When it is done, it should look like:
9486

9587
(Even though you will encounter version numbers in the file of past changes,
9688
you should not put the rustc version you expect your stabilization to happen in,
97-
but instead `CURRENT_RUSTC_VERSION`)
89+
but instead use `CURRENT_RUSTC_VERSION`.)
9890

9991
### Removing existing uses of the feature-gate
10092

101-
Next search for the feature string (in this case, `pub_restricted`)
93+
Next, search for the feature string (in this case, `pub_restricted`)
10294
in the codebase to find where it appears. Change uses of
10395
`#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders
10496
under `library/` and `compiler/` but not the toplevel `tests/` one) to be
@@ -116,8 +108,8 @@ simply remove the test.
116108
Most importantly, remove the code which flags an error if the
117109
feature-gate is not present (since the feature is now considered
118110
stable). If the feature can be detected because it employs some
119-
new syntax, then a common place for that code to be is in the
120-
same `compiler/rustc_ast_passes/src/feature_gate.rs`.
111+
new syntax, then a common place for that code to be is in
112+
`compiler/rustc_ast_passes/src/feature_gate.rs`.
121113
For example, you might see code like this:
122114

123115
```rust,ignore
@@ -166,22 +158,37 @@ if something { /* XXX */ }
166158

167159
## Team nominations
168160

169-
After the stabilization PR is opened with the stabilization report, wait a bit for potential immediate comments. When such immediate comments "simmer down" and you feel the PR is ready for consideration by the lang team, you can [nominate the PR](https://lang-team.rust-lang.org/how_to/nominate.html) to get it on the list for discussion in the next meeting. You should also cc the other interacting teams when applicable to review the language feature being stabilized and the stabilization report:
161+
When opening the stabilization PR, CC the lang team (`@rust-lang/lang`) and any other teams to whom the feature is relevant, e.g.:
162+
163+
- `@rust-lang/types`, for type system interactions.
164+
- `@rust-lang/opsem`, for interactions with unsafe code.
165+
- `@rust-lang/compiler`, for implementation robustness.
166+
- `@rust-lang/libs-api`, for changes to the standard library API or its guarantees.
167+
- `@rust-lang/lang-docs`, for questions about how this should be documented in the Reference.
170168

171-
* `@rust-lang/types`, to look for type system interactions
172-
* `@rust-lang/compiler`, to review implementation robustness
173-
* `@rust-lang/opsem`, if this feature interacts with unsafe code and can create undefined behavior
174-
* `@rust-lang/libs-api`, if there are additions to the standard library that affects standard library API or their guarantees
169+
After the stabilization PR is opened with the stabilization report, wait a bit for any immediate comments. When such comments "simmer down" and you feel the PR is ready for consideration by the lang team, [nominate the PR](https://lang-team.rust-lang.org/how_to/nominate.html) to get it on the agenda for consideration in an upcoming lang meeting.
175170

176-
If you are not an organization member, you can simply ask your assigned reviewer to cc the relevant teams on your behalf.
171+
If you are not a `rust-lang` organization member, you can ask your assigned reviewer to CC the relevant teams on your behalf.
177172

178-
## FCP proposed on the PR
173+
## Proposed FCP on the PR
179174

180-
Finally, some member of the team responsible for tracking this feature agrees with stabilizing this feature, will
181-
start the FCP (final-comment-period) process by commenting
175+
After the lang team and other relevant teams review the stabilization, and after you have answered any questions they may have had, a member of one of the teams may propose to accept the stabilization by commenting:
182176

183177
```text
184178
@rfcbot fcp merge
185179
```
186180

187-
The rest of the team members will review the proposal. If the final decision is to stabilize, the PR will be reviewed by the compiler team like any other PR.
181+
Once enough team members have reviewed, the PR will move into a "final comment period". If no new concerns are raised, this period will complete and the PR can be merged after implementation review in the usual way.
182+
183+
## Reviewing and merging stabilizations
184+
185+
On a stabilization, before giving it the `r+`, ensure that the PR:
186+
187+
- Matches what the team proposed for stabilization.
188+
- Includes any changes the team decided to request along the way in order to resolve or avoid concerns.
189+
- Is otherwise exactly what is described in the stabilization report and in any relevant RFCs or prior lang FCPs.
190+
- Does not expose on stable behaviors other than those specified and accepted for stabilization.
191+
- Has sufficient tests to convincingly demonstrate these things.
192+
- Is accompanied by a PR to the Reference than has been reviewed and approved by a member of lang-docs.
193+
194+
In particular, when reviewing the PR, keep an eye out for any user-visible detail that the lang team failed to consider and specify. If you find one, describe it and nominate the PR for the lang team.

0 commit comments

Comments
 (0)