|
1 | 1 | # Stabilizing features
|
2 | 2 |
|
3 |
| -**Status:** Stub |
| 3 | +**Status:** Current |
| 4 | +**Last Updated:** 2022/03/03 |
4 | 5 |
|
5 |
| -Feature stabilization involves adding `#[stable]` attributes. They may be introduced alongside new trait impls or replace existing `#[unstable]` attributes. |
| 6 | +Feature stabilization involves adding `#[stable]` attributes. They may be |
| 7 | +introduced alongside new trait impls or replace existing `#[unstable]` |
| 8 | +attributes. |
6 | 9 |
|
7 |
| -Stabilization goes through the Libs FCP process, which occurs on the [tracking issue](./tracking-issues.md) for the feature. |
| 10 | +Stabilization goes through the Libs FCP process, which occurs on the [tracking |
| 11 | +issue](./tracking-issues.md) for the feature. |
8 | 12 |
|
9 | 13 | ## Before writing a PR to stabilize a feature
|
10 | 14 |
|
11 |
| -Check to see if a FCP has completed first. If not, either ping `@rust-lang/libs` or leave a comment asking about the status of the feature. |
| 15 | +Check to see if a FCP has completed first. If not, either ping |
| 16 | +`@rust-lang/libs` or leave a comment asking about the status of the feature. |
12 | 17 |
|
13 |
| -This will save you from opening a stabilization PR and having it need regular rebasing while the FCP process runs its course. |
| 18 | +This will save you from opening a stabilization PR and having it need regular |
| 19 | +rebasing while the FCP process runs its course. |
14 | 20 |
|
15 |
| -## Writing a stabilization PR |
| 21 | +## Partial Stabilizations |
| 22 | + |
| 23 | +When you only wish to stabilize a subset of an existing feature your first step |
| 24 | +should be to split the feature into multiple features, each with their own |
| 25 | +tracking issues. |
16 | 26 |
|
17 |
| -- Replace any `#[unstable]` attributes for the given feature with stable ones. The value of the `since` field is usually the current `nightly` version. |
18 |
| -- Remove any `#![feature()]` attributes that were previously required. |
19 |
| -- Submit a PR with a stabilization report. |
| 27 | +You can see an example of partially stabilizing a feature with tracking issues |
| 28 | +[#71146](https://github.com/rust-lang/rust/issues/71146) and [XXXXX]() with FCP |
| 29 | +and the associated implementation PR [XXXXX](). |
20 | 30 |
|
21 | 31 | ## When there's `const` involved
|
22 | 32 |
|
23 |
| -Const functions can be stabilized in a PR that replaces `#[rustc_const_unstable]` attributes with `#[rustc_const_stable]` ones. The [Constant Evaluation WG](https://github.com/rust-lang/const-eval) should be pinged for input on whether or not the `const`-ness is something we want to commit to. If it is an intrinsic being exposed that is const-stabilized then `@rust-lang/lang` should also be included in the FCP. |
| 33 | +Const functions can be stabilized in a PR that replaces |
| 34 | +`#[rustc_const_unstable]` attributes with `#[rustc_const_stable]` ones. The |
| 35 | +[Constant Evaluation WG](https://github.com/rust-lang/const-eval) should be |
| 36 | +pinged for input on whether or not the `const`-ness is something we want to |
| 37 | +commit to. If it is an intrinsic being exposed that is const-stabilized then |
| 38 | +`@rust-lang/lang` should also be included in the FCP. |
| 39 | + |
| 40 | +Check whether the function internally depends on other unstable `const` |
| 41 | +functions through `#[allow_internal_unstable]` attributes and consider how the |
| 42 | +function could be implemented if its internally unstable calls were removed. |
| 43 | +See the _Stability attributes_ page for more details on |
| 44 | +`#[allow_internal_unstable]`. |
| 45 | + |
| 46 | +Where `unsafe` and `const` is involved, e.g., for operations which are |
| 47 | +"unconst", that the const safety argument for the usage also be documented. |
| 48 | +That is, a `const fn` has additional determinism (e.g. run-time/compile-time |
| 49 | +results must correspond and the function's output only depends on its |
| 50 | +inputs...) restrictions that must be preserved, and those should be argued when |
| 51 | +`unsafe` is used. |
| 52 | + |
| 53 | +## Writing a stabilization PR |
| 54 | + |
| 55 | +To stabilize a feature, follow these steps: |
| 56 | + |
| 57 | +0. (Optional) For partial stabilizations, create a new tracking issue for |
| 58 | + either the subset being stabilized or the subset being left unstable as |
| 59 | + preferred. If you're unsure which way is best ask a libs-api team member. |
| 60 | +0. Ask a **@rust-lang/libs-api** member to start an FCP on the tracking issue |
| 61 | + and wait for the FCP to complete (with `disposition-merge`). |
| 62 | +0. Change `#[unstable(...)]` to `#[stable(since = "version")]`. `version` |
| 63 | + should be the *current nightly*, i.e. stable+2. You can see which version is |
| 64 | + the current nightly [on Forge](https://forge.rust-lang.org/#current-release-versions). |
| 65 | +0. Remove `#![feature(...)]` from any test or doc-test for this API. If the |
| 66 | + feature is used in the compiler or tools, remove it from there as well. |
| 67 | +0. If applicable, change `#[rustc_const_unstable(...)]` to |
| 68 | + `#[rustc_const_stable(since = "version")]`. |
| 69 | +0. Open a PR against `rust-lang/rust`. |
| 70 | + - Add the appropriate labels: `@rustbot modify labels: +T-libs-api`. |
| 71 | + - Link to the tracking issue and say "Closes #XXXXX". |
24 | 72 |
|
25 |
| -Check whether the function internally depends on other unstable `const` functions through `#[allow_internal_unstable]` attributes and consider how the function could be implemented if its internally unstable calls were removed. See the _Stability attributes_ page for more details on `#[allow_internal_unstable]`. |
| 73 | +You can see an example of stabilizing a feature with |
| 74 | +[tracking issue #81656 with FCP](https://github.com/rust-lang/rust/issues/81656) |
| 75 | +and the associated |
| 76 | +[implementation PR #84642](https://github.com/rust-lang/rust/pull/84642). |
26 | 77 |
|
27 |
| -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. |
|
0 commit comments