Skip to content

Commit 5aec431

Browse files
Centrilmark-i-m
authored andcommitted
Update feature gating docs to fit reality (rust-lang#455)
1 parent bda375e commit 5aec431

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/implementing_new_features.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ of concept so that people can see what you are talking about.
3535

3636
That starts a "proposed final comment period" (pFCP), which requires
3737
all members of the team to sign off the FCP. After they all do so,
38-
there's a week long "final comment period" where everybody can comment,
38+
there's a 10 day long "final comment period" where everybody can comment,
3939
and if no new concerns are raised, the PR/issue gets FCP approval.
4040

4141
## The logistics of writing features
@@ -119,10 +119,13 @@ a new unstable feature:
119119
1. Open a [tracking issue] -
120120
if you have an RFC, you can use the tracking issue for the RFC.
121121

122+
The tracking issue should be labeled with at least `C-tracking-issue`.
123+
For a language feature, a label `F-feature_name` should be added as well.
124+
122125
2. Pick a name for the feature gate (for RFCs, use the name
123126
in the RFC).
124127

125-
3. Add a feature gate declaration to `libsyntax/feature_gate.rs`
128+
3. Add a feature gate declaration to `libsyntax/active.rs`
126129
in the active `declare_features` block:
127130

128131
```rust,ignore
@@ -140,8 +143,8 @@ For example:
140143
( active, match_beginning_vert, "1.21.0", Some(44101), None),
141144
```
142145

143-
The current version is not actually important – the important
144-
version is when you are stabilizing a feature.
146+
When added, the current version should be the one for the current nightly.
147+
Once the feature is moved to `accepted.rs`, the version is changed to that nightly version.
145148

146149
4. Prevent usage of the new feature unless the feature gate is set.
147150
You can check it in most places in the compiler using the
@@ -153,10 +156,14 @@ version is when you are stabilizing a feature.
153156
the pre-feature behavior or raise an error, depending on
154157
what makes sense.
155158

159+
For features introducing new syntax, pre-expansion gating should be used instead.
160+
To do so, extend the [`GatedSpans`] struct, add spans to it during parsing,
161+
and then finally feature-gate all the spans in [`feature_gate::check::check_crate`].
162+
156163
5. Add a test to ensure the feature cannot be used without
157164
a feature gate, by creating `feature-gate-$feature_name.rs`
158165
and `feature-gate-$feature_name.stderr` files under the
159-
`src/test/ui/feature-gates` directory.
166+
directory where the other tests for your feature reside.
160167

161168
6. Add a section to the unstable book, in
162169
`src/doc/unstable-book/src/language-features/$feature_name.md`.
@@ -167,6 +174,8 @@ version is when you are stabilizing a feature.
167174
8. Get your PR reviewed and land it. You have now successfully
168175
implemented a feature in Rust!
169176

177+
[`GatedSpans`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/struct.GatedSpans.html
178+
[`feature_gate::check::check_crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/check/fn.check_crate.html
170179
[value the stability of Rust]: https://github.com/rust-lang/rfcs/blob/master/text/1122-language-semver.md
171180
[stability in code]: #stability-in-code
172181
[here]: https://rust-lang.github.io/rustc-guide/stabilization_guide.html

0 commit comments

Comments
 (0)