You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: src/implementing_new_features.md
+41-34Lines changed: 41 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ When you want to implement a new significant feature in the compiler,
6
6
you need to go through this process to make sure everything goes
7
7
smoothly.
8
8
9
-
**NOTE: this section is for *language* features, not *library* features,
9
+
**NOTE: This section is for *language* features, not *library* features,
10
10
which use [a different process].**
11
11
12
12
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
92
92
the world using the stabilization process described [here].
93
93
Until then, the feature is not set in stone: every part of the
94
94
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.
97
97
98
98
### Tracking Issues
99
99
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.
104
103
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.
107
105
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].
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.
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".
213
220
214
-
Some example Call for Testing blog posts:
221
+
Some earlier such blog posts include:
215
222
216
223
1.[The push for GATs stabilization](https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push/)
217
224
2.[Changes to `impl Trait` in Rust 2024](https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html)
218
225
3.[Async Closures MVP: Call for Testing!](https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing/)
219
226
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:
221
228
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)
223
230
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.
225
232
226
-
## Affiliated work
233
+
## Polishing
227
234
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:
229
236
230
237
- 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.
235
242
236
243
## Stabilization
237
244
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].
@@ -26,14 +29,9 @@ If there wasn't documentation there, it needs to be added.
26
29
27
30
Places that may need updated documentation:
28
31
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.
37
35
-[Rust by Example]: As needed.
38
36
39
37
Prepare PRs to update documentation involving this new feature
@@ -45,29 +43,23 @@ has completed. Meanwhile, we can proceed to the next step.
45
43
46
44
Author a stabilization report using the [template found in this repository][srt].
47
45
48
-
Stabilization reports summarize:
46
+
The stabilization reports summarizes:
49
47
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.
52
50
- The work that has been done since the RFC was accepted, acknowledging the main contributors that helped drive the language feature forward.
53
51
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.
55
53
56
54
[srt]: ./stabilization_report_template.md
57
55
58
56
The stabilization report is typically posted as the main comment on the stabilization PR (see the next section).
59
57
60
-
## Stabilization PR for a language feature
58
+
## Stabilization PR
61
59
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.
64
61
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.
71
63
72
64
### Updating the feature-gate listing
73
65
@@ -94,11 +86,11 @@ When it is done, it should look like:
94
86
95
87
(Even though you will encounter version numbers in the file of past changes,
96
88
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`.)
98
90
99
91
### Removing existing uses of the feature-gate
100
92
101
-
Next search for the feature string (in this case, `pub_restricted`)
93
+
Next, search for the feature string (in this case, `pub_restricted`)
102
94
in the codebase to find where it appears. Change uses of
103
95
`#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders
104
96
under `library/` and `compiler/` but not the toplevel `tests/` one) to be
@@ -116,8 +108,8 @@ simply remove the test.
116
108
Most importantly, remove the code which flags an error if the
117
109
feature-gate is not present (since the feature is now considered
118
110
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`.
121
113
For example, you might see code like this:
122
114
123
115
```rust,ignore
@@ -166,22 +158,37 @@ if something { /* XXX */ }
166
158
167
159
## Team nominations
168
160
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.
170
168
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.
175
170
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.
177
172
178
-
## FCP proposed on the PR
173
+
## Proposed FCP on the PR
179
174
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:
182
176
183
177
```text
184
178
@rfcbot fcp merge
185
179
```
186
180
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