Skip to content

Commit 4e22188

Browse files
committed
add detailed section that scottmcm wrote for rustc dev guide
1 parent fb852e9 commit 4e22188

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

src/feature-lifecycle/stabilization.md

+54-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This will save you from opening a stabilization PR and having it need regular re
1515

1616
## Partial Stabilizations
1717

18-
When you only wish to stabilize a subset of an existing feature your first step should be to split the feature into multiple features, each with their own tracking issues.
18+
When you only wish to stabilize a subset of an existing feature your first step should be to split the feature into multiple features, each with their own tracking issues. How you split up that feature is situational and depends on the specific feature and how you're splitting it up, so in some cases you may want to create a new tracking issue for the portion being stabilized, and in other situations you may want to use the new tracking issue to track the portion being left unstable. If you're unsure how to split up the issue you can always ask a libs-api team member for guidance in the original tracking issue or in the [libs team zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs).
1919

2020
You can see an example of partially stabilizing a feature with tracking issues [#71146](https://github.com/rust-lang/rust/issues/71146) and [XXXXX]() with FCP and the associated implementation PR [XXXXX]().
2121

@@ -27,11 +27,62 @@ Check whether the function internally depends on other unstable `const` function
2727

2828
Where `unsafe` and `const` is involved, e.g., for operations which are "unconst", that the const safety argument for the usage also be documented. That is, a `const fn` has additional determinism (e.g. run-time/compile-time results must correspond and the function's output only depends on its inputs...) restrictions that must be preserved, and those should be argued when `unsafe` is used.
2929

30-
## Writing a stabilization PR
30+
## Stabilization PR for Library Features
31+
32+
Once we have decided to stabilize a feature, we need to have a PR that actually makes that stabilization happen. These kinds of PRs are a great way to get involved in Rust, as they're typically small -- just updating attributes.
33+
34+
Here is a general guide to how to stabilize a feature -- every feature is different, of course, so some features may require steps beyond what this guide talks about.
35+
36+
### Update the stability attributes on the items
37+
38+
Library items are marked unstable via the `#[unstable]` attribute, like this:
39+
40+
```rust,ignore
41+
#[unstable(feature = "total_cmp", issue = "72599")]
42+
pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering { ... }
43+
```
44+
45+
You'll need to change that to a `#[stable]` attribute with a version:
46+
47+
```rust,ignore
48+
#[stable(feature = "total_cmp", since = "1.61.0")]
49+
```
50+
51+
Note that, the version number is updated to be the version number of the stable release where this feature will appear. This can be found by consulting [the forge](https://forge.rust-lang.org/#current-release-versions). Specifically, you'll want to use the version labelled "Nightly". That's two versions higher than the current stable release, as what's currently in beta will be the next stable release, and any change you're making now will be in the one after that.
52+
53+
### Remove feature gates from doctests
54+
55+
All the doctests on the items being stabilized will be enabling the unstable feature, so now that it's stable those attributes are no longer needed and should be removed.
56+
57+
`````diff
58+
/// # Examples
59+
///
60+
/// ```
61+
-/// #![feature(total_cmp)]
62+
-///
63+
/// assert_eq!(0.0_f32.total_cmp(&-0.0), std::cmp::Ordering::Greater);
64+
/// ```
65+
`````
66+
67+
The most obvious place to find these is on the item itself, but it's worth searching the whole library. Often you'll find other unstable methods that were also using it in their tests.
68+
69+
### Remove feature gates from the compiler
70+
71+
The compiler builds with nightly features allowed, so you may find uses of the feature there as well. These also need to be removed.
72+
73+
```diff
74+
#![feature(once_cell)]
75+
#![feature(never_type)]
76+
-#![feature(total_cmp)]
77+
#![feature(trusted_step)]
78+
#![feature(try_blocks)]
79+
```
80+
81+
## Stabilization PR Checklist
3182

3283
To stabilize a feature, follow these steps:
3384

34-
0. (Optional) For partial stabilizations, create a new tracking issue for either the subset being stabilized or the subset being left unstable as preferred. If you're unsure which way is best ask a libs-api team member.
85+
0. (Optional) For partial stabilizations, create a new tracking issue for either the subset being stabilized or the subset being left unstable, whichever makes the most sense based on the situation.
3586
0. Ask a **@rust-lang/libs-api** member to start an FCP on the tracking issue and wait for the FCP to complete (with `disposition-merge`).
3687
0. Change `#[unstable(...)]` to `#[stable(since = "version")]`. `version` should be the *current nightly*, i.e. stable+2. You can see which version is the current nightly [on Forge](https://forge.rust-lang.org/#current-release-versions).
3788
0. Remove `#![feature(...)]` from any test or doc-test for this API. If the feature is used in the compiler or tools, remove it from there as well.

0 commit comments

Comments
 (0)