Skip to content

Commit 6886f4e

Browse files
committed
sembr implementing_new_features.md
1 parent ef92ea1 commit 6886f4e

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

src/implementing_new_features.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,73 @@ See also [the Rust Language Design Team's procedures][lang-propose] for proposin
1111

1212
## The @rfcbot FCP process
1313

14-
When the change is small, uncontroversial, non-breaking, and does not affect the stable language in any user-observable ways or add any new unstable features, then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code. However, if not, more must be done. Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights).
14+
When the change is small, uncontroversial, non-breaking, and does not affect the stable language in any user-observable ways or add any new unstable features, then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code.
15+
However, if not, more must be done.
16+
Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights).
1517

16-
For changes that need the consensus of a team, we us the process of proposing a final comment period (FCP). If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one; unless they have a concern themselves, they should.
18+
For changes that need the consensus of a team, we us the process of proposing a final comment period (FCP).
19+
If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one;
20+
unless they have a concern themselves, they should.
1721

18-
The FCP process is only needed if you need consensus – if no processes require consensus for your change and you don't think anyone would have a problem with it, it's OK to rely on only an r+. For example, it is OK to add or modify unstable command-line flags or attributes in the reserved compiler-internal `rustc_` namespace without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem. Some teams have lighter weight processes that they use in scenarios like this; for example, the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) as a lightweight way to garner support and feedback without requiring full consensus.
22+
The FCP process is only needed if you need consensus – if no processes require consensus for your change and you don't think anyone would have a problem with it, it's OK to rely on only an r+.
23+
For example, it is OK to add or modify unstable command-line flags or attributes in the reserved compiler-internal `rustc_` namespace without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem.
24+
Some teams have lighter weight processes that they use in scenarios like this;
25+
for example, the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) as a lightweight way to garner support and feedback without requiring full consensus.
1926

2027
[mcp]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#how-do-i-submit-an-mcp
2128

2229
You don't need to have the implementation fully ready for r+ to propose an FCP, but it is generally a good idea to have at least a proof of concept so that people can see what you are talking about.
2330

24-
When an FCP is proposed, it requires all members of the team to sign off on the FCP. After they all do so, there's a 10-day-long "final comment period" (hence the name) where everybody can comment, and if no concerns are raised, the PR/issue gets FCP approval.
31+
When an FCP is proposed, it requires all members of the team to sign off on the FCP.
32+
After they all do so, there's a 10-day-long "final comment period" (hence the name) where everybody can comment, and if no concerns are raised, the PR/issue gets FCP approval.
2533

2634
## The logistics of writing features
2735

2836
There are a few "logistical" hoops you might need to go through in order to implement a feature in a working way.
2937

3038
### Warning Cycles
3139

32-
In some cases, a feature or bugfix might break some existing programs in some edge cases. In that case, you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints).
40+
In some cases, a feature or bugfix might break some existing programs in some edge cases.
41+
In that case, you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints).
3342

3443
### Stability
3544

36-
We [value the stability of Rust]. Code that works and runs on stable should (mostly) not break. Because of that, we don't want to release a feature to the world with only team consensus and code review - we want to gain real-world experience on using that feature on nightly, and we might want to change the feature based on that experience.
45+
We [value the stability of Rust].
46+
Code that works and runs on stable should (mostly) not break.
47+
Because of that, we don't want to release a feature to the world with only team consensus and code review - we want to gain real-world experience on using that feature on nightly, and we might want to change the feature based on that experience.
3748

3849
To allow for that, we must make sure users don't accidentally depend on that new feature - otherwise, especially if experimentation takes time or is delayed and the feature takes the trains to stable, it would end up de facto stable and we'll not be able to make changes in it without breaking people's code.
3950

40-
The way we do that is that we make sure all new features are feature gated - they can't be used without enabling a feature gate (`#[feature(foo)]`), which can't be done in a stable/beta compiler. See the [stability in code] section for the technical details.
51+
The way we do that is that we make sure all new features are feature gated - they can't be used without enabling a feature gate (`#[feature(foo)]`), which can't be done in a stable/beta compiler.
52+
See the [stability in code] section for the technical details.
4153

42-
Eventually, after we gain enough experience using the feature, make the necessary changes, and are satisfied, we expose it to the world using the stabilization process described [here]. Until then, the feature is not set in stone: every part of the feature can be changed, or the feature might be completely rewritten or removed. Features do not gain tenure by being unstable and unchanged for long periods of time.
54+
Eventually, after we gain enough experience using the feature, make the necessary changes, and are satisfied, we expose it to the world using the stabilization process described [here].
55+
Until then, the feature is not set in stone: every part of the feature can be changed, or the feature might be completely rewritten or removed.
56+
Features do not gain tenure by being unstable and unchanged for long periods of time.
4357

4458
### Tracking Issues
4559

4660
To keep track of the status of an unstable feature, the experience we get while using it on
4761
nightly, and of the concerns that block its stabilization, every feature-gate needs a tracking
48-
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.
62+
issue.
63+
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.
4964

5065
For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that.
5166

52-
For other features, create a tracking issue for that feature. The issue title should be "Tracking issue for YOUR FEATURE". Use the ["Tracking Issue" issue template][template].
67+
For other features, create a tracking issue for that feature.
68+
The issue title should be "Tracking issue for YOUR FEATURE".
69+
Use the ["Tracking Issue" issue template][template].
5370

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

5673
### Lang experiments
5774

5875
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].
5976

60-
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` and `@rust-lang/lang-advisors`. When the experiment is approved, the tracking issue will be marked as `B-experimental`.
77+
To propose a new lang experiment, open an issue in `rust-lang/rust` that describes the motivation and the intended solution.
78+
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.
79+
Nominate the issue for the lang team and CC `@rust-lang/lang` and `@rust-lang/lang-advisors`.
80+
When the experiment is approved, the tracking issue will be marked as `B-experimental`.
6181

6282
Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature.
6383

@@ -110,11 +130,15 @@ The below steps needs to be followed in order to implement a new unstable featur
110130

111131
1. Prevent usage of the new feature unless the feature gate is set. You can check it in most places in the compiler using the expression `tcx.features().$feature_name()`.
112132

113-
If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense. Errors should generally use [`rustc_session::parse::feature_err`]. For an example of adding an error, see [#81015].
133+
If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense.
134+
Errors should generally use [`rustc_session::parse::feature_err`].
135+
For an example of adding an error, see [#81015].
114136

115-
For features introducing new syntax, pre-expansion gating should be used instead. During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`.
137+
For features introducing new syntax, pre-expansion gating should be used instead.
138+
During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`.
116139

117-
After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies features. Exactly how it is gated depends on the exact type of feature, but most likely will use the `gate_all!()` macro.
140+
After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies features.
141+
Exactly how it is gated depends on the exact type of feature, but most likely will use the `gate_all!()` macro.
118142

119143
1. Add a test to ensure the feature cannot be used without a feature gate, by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`. You can generate the corresponding `.stderr` file by running `./x test tests/ui/feature-gates/ --bless`.
120144

@@ -136,23 +160,27 @@ The below steps needs to be followed in order to implement a new unstable featur
136160

137161
## Call for testing
138162

139-
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".
163+
Once the implementation is complete, the feature will be available to nightly users but not yet part of stable Rust.
164+
This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a "call for testing".
140165

141166
Some earlier such blog posts include:
142167

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

147-
Alternatively, [*This Week in Rust*][twir] has a [section][twir-cft] for this. One example of this having been used is:
172+
Alternatively, [*This Week in Rust*][twir] has a [section][twir-cft] for this.
173+
One example of this having been used is:
148174

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

151177
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.
152178

153179
## Polishing
154180

155-
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:
181+
Giving users a polished experience means more than just implementing the feature in rustc.
182+
We need to think about all of the tools and resources that we ship.
183+
This work includes:
156184

157185
- Documenting the language feature in the [Rust Reference][reference].
158186
- Extending [`rustfmt`] to format any new syntax (if applicable).
@@ -162,7 +190,9 @@ Giving users a polished experience means more than just implementing the feature
162190

163191
## Stabilization
164192

165-
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].
193+
The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users.
194+
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).
195+
To learn more about stabilization, see the [stabilization guide][stab].
166196

167197

168198
[stab]: ./stabilization_guide.md

0 commit comments

Comments
 (0)