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
Copy file name to clipboardExpand all lines: src/stabilization_guide.md
+43-16Lines changed: 43 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
# Request for stabilization
2
2
3
-
**NOTE**: This page is about stabilizing *language* features. For stabilizing *library* features, see [Stabilizing a library feature].
3
+
**NOTE**: This page is about stabilizing *language* features.
4
+
For stabilizing *library* features, see [Stabilizing a library feature].
4
5
5
6
[Stabilizing a library feature]: ./stability.md#stabilizing-a-library-feature
6
7
7
-
Once an unstable feature has been well-tested with no outstanding concerns, anyone may push for its stabilization, though involving the people who have worked on it is prudent. Follow these steps:
8
+
Once an unstable feature has been well-tested with no outstanding concerns, anyone may push for its stabilization, though involving the people who have worked on it is prudent.
9
+
Follow these steps:
8
10
9
11
## Write an RFC, if needed
10
12
@@ -16,16 +18,23 @@ If the feature was part of a [lang experiment], the lang team generally will wan
16
18
17
19
<aid="updating-documentation"></a>
18
20
19
-
The feature might be documented in the [`Unstable Book`], located at [`src/doc/unstable-book`]. Remove the page for the feature gate if it exists. Integrate any useful parts of that documentation in other places.
21
+
The feature might be documented in the [`Unstable Book`], located at [`src/doc/unstable-book`].
22
+
Remove the page for the feature gate if it exists.
23
+
Integrate any useful parts of that documentation in other places.
20
24
21
25
Places that may need updated documentation include:
22
26
23
27
-[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.
24
-
-[The Book]: This is updated as needed. If you're not sure, please open an issue on this repository and it can be discussed.
25
-
- Standard library documentation: This is updated 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. Review also the keyword documentation and ABI documentation in the standard library, as these sometimes needs updates for language changes.
28
+
-[The Book]: This is updated as needed.
29
+
If you're not sure, please open an issue on this repository and it can be discussed.
30
+
- Standard library documentation: This is updated as needed.
31
+
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.
32
+
Review also the keyword documentation and ABI documentation in the standard library, as these sometimes need updates for language changes.
26
33
-[Rust by Example]: This is updated as needed.
27
34
28
-
Prepare PRs to update documentation involving this new feature for the repositories mentioned above. Maintainers of these repositories will keep these PRs open until the whole stabilization process has completed. Meanwhile, we can proceed to the next step.
35
+
Prepare PRs to update documentation involving this new feature for the repositories mentioned above.
36
+
Maintainers of these repositories will keep these PRs open until the whole stabilization process has completed.
37
+
Meanwhile, we can proceed to the next step.
29
38
30
39
## Write a stabilization report
31
40
@@ -34,7 +43,8 @@ Author a stabilization report using the [template found in this repository][srt]
34
43
The stabilization reports summarizes:
35
44
36
45
- 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.
37
-
- 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.
46
+
- Often, the final stabilized language feature has significant design deviations from the original RFC.
47
+
That's OK, but these deviations must be highlighted and explained carefully.
38
48
- The work that has been done since the RFC was accepted, acknowledging the main contributors that helped drive the language feature forward.
39
49
40
50
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.
@@ -51,14 +61,19 @@ Before the stabilization will be considered by the lang team, there must be a co
51
61
52
62
### Updating the feature-gate listing
53
63
54
-
There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. Search for the `declare_features!` macro. There should be an entry for the feature you are aiming to stabilize, something like (this example is taken from [rust-lang/rust#32409]:
64
+
There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`].
65
+
Search for the `declare_features!` macro.
66
+
There should be an entry for the feature you are aiming to stabilize,
67
+
something like the following (taken from [rust-lang/rust#32409]:
The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`]. Entries in the `declare_features!` call are sorted, so find the correct place. When it is done, it should look like:
74
+
The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`].
75
+
Entries in the `declare_features!` call are sorted, so find the correct place.
76
+
When it is done, it should look like:
62
77
63
78
```rust,ignore
64
79
// pub(restricted) visibilities (RFC 1422)
@@ -70,27 +85,36 @@ The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`]. En
70
85
71
86
### Removing existing uses of the feature-gate
72
87
73
-
Next, search for the feature string (in this case, `pub_restricted`) in the codebase to find where it appears. Change uses of `#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one) to be `#![cfg_attr(bootstrap, feature(XXX))]`. This includes the feature-gate only for stage0, which is built using the current beta (this is needed because the feature is still unstable in the current beta).
88
+
Next, search for the feature string (in this case, `pub_restricted`) in the codebase to find where it appears.
89
+
Change uses of `#![feature(XXX)]` from the `std` and any rustc crates
90
+
(which includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one)
91
+
to be `#![cfg_attr(bootstrap, feature(XXX))]`.
92
+
This includes the feature-gate only for stage0, which is built using the current beta (this is needed because the feature is still unstable in the current beta).
74
93
75
94
Also, remove those strings from any tests (e.g. under `tests/`). If there are tests specifically targeting the feature-gate (i.e., testing that the feature-gate is required to use the feature, but nothing else), simply remove the test.
76
95
77
96
### Do not require the feature-gate to use the feature
78
97
79
-
Most importantly, remove the code which flags an error if the feature-gate is not present (since the feature is now considered stable). If the feature can be detected because it employs some new syntax, then a common place for that code to be is in `compiler/rustc_ast_passes/src/feature_gate.rs`. For example, you might see code like this:
98
+
Most importantly, remove the code which flags an error if the feature-gate is not present (since the feature is now considered stable).
99
+
If the feature can be detected because it employs some new syntax, then a common place for that code to be is in `compiler/rustc_ast_passes/src/feature_gate.rs`.
100
+
For example, you might see code like this:
80
101
81
102
```rust,ignore
82
103
gate_all!(pub_restricted, "`pub(restricted)` syntax is experimental");
83
104
```
84
105
85
-
The `gate_all!` macro reports an error if the `pub_restricted` feature is not enabled. It is not needed now that `pub(restricted)` is stable.
106
+
The `gate_all!` macro reports an error if the `pub_restricted` feature is not enabled.
107
+
It is not needed now that `pub(restricted)` is stable.
86
108
87
109
For more subtle features, you may find code like this:
88
110
89
111
```rust,ignore
90
112
if self.tcx.features().async_fn_in_dyn_trait() { /* XXX */ }
91
113
```
92
114
93
-
This `pub_restricted` field (named after the feature) would ordinarily be false if the feature flag is not present and true if it is. So transform the code to assume that the field is true. In this case, that would mean removing the `if` and leaving just the `/* XXX */`.
115
+
This `pub_restricted` field (named after the feature) would ordinarily be false if the feature flag is not present and true if it is.
116
+
So, transform the code to assume that the field is true.
117
+
In this case, that would mean removing the `if` and leaving just the `/* XXX */`.
94
118
95
119
```rust,ignore
96
120
if self.tcx.sess.features.borrow().pub_restricted { /* XXX */ }
@@ -126,7 +150,8 @@ When opening the stabilization PR, CC the lang team and its advisors (`@rust-lan
126
150
-`@rust-lang/libs-api`, for changes to the standard library API or its guarantees.
127
151
-`@rust-lang/lang-docs`, for questions about how this should be documented in the Reference.
128
152
129
-
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.
153
+
After the stabilization PR is opened with the stabilization report, wait a bit for any immediate comments.
154
+
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.
130
155
131
156
If you are not a `rust-lang` organization member, you can ask your assigned reviewer to CC the relevant teams on your behalf.
132
157
@@ -138,7 +163,8 @@ After the lang team and other relevant teams review the stabilization, and after
138
163
@rfcbot fcp merge
139
164
```
140
165
141
-
Once enough team members have reviewed, the PR will move into a "final comment period" (FCP). If no new concerns are raised, this period will complete and the PR can be merged after implementation review in the usual way.
166
+
Once enough team members have reviewed, the PR will move into a "final comment period" (FCP).
167
+
If no new concerns are raised, this period will complete and the PR can be merged after implementation review in the usual way.
142
168
143
169
## Reviewing and merging stabilizations
144
170
@@ -151,4 +177,5 @@ On a stabilization, before giving it the `r+`, ensure that the PR:
151
177
- Has sufficient tests to convincingly demonstrate these things.
152
178
- Is accompanied by a PR to the Reference than has been reviewed and approved by a member of lang-docs.
153
179
154
-
In particular, when reviewing the PR, keep an eye out for any user-visible details that the lang team failed to consider and specify. If you find one, describe it and nominate the PR for the lang team.
180
+
In particular, when reviewing the PR, keep an eye out for any user-visible details that the lang team failed to consider and specify.
181
+
If you find one, describe it and nominate the PR for the lang team.
0 commit comments