Skip to content

Commit 23b0479

Browse files
camelidJoshua Nelson
authored and
Joshua Nelson
committed
Move instructions for adding a feature gate to "Feature Gates"
1 parent 72eca8f commit 23b0479

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

src/feature-gates.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
# Feature Gates
22

3-
This chapter is intended to provide basic help for modifying feature gates. See
4-
["Stability in code"][stability-section] for help with *adding* feature gates.
3+
This chapter is intended to provide basic help for adding, removing, and
4+
modifying feature gates.
55

6-
[stability-section]: ./implementing_new_features.md#stability-in-code
6+
7+
## Adding a feature gate
8+
9+
See ["Stability in code"][stability-section] for help with adding a new feature;
10+
this section just covers how to add the feature gate *declaration*.
11+
12+
Add a feature gate declaration to `rustc_feature/src/active.rs` in the active
13+
`declare_features` block:
14+
15+
```rust,ignore
16+
/// description of feature
17+
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number), $edition)
18+
```
19+
20+
where `$edition` has the type `Option<Edition>`, and is typically
21+
just `None`.
22+
23+
For example:
24+
25+
```rust,ignore
26+
/// Allows defining identifiers beyond ASCII.
27+
(active, non_ascii_idents, "1.0.0", Some(55467), None),
28+
```
29+
30+
When added, the current version should be the one for the current nightly.
31+
Once the feature is moved to `accepted.rs`, the version is changed to that
32+
nightly version.
733

834

935
## Removing a feature gate
@@ -63,3 +89,6 @@ to follow when [removing a feature gate][removing]):
6389
/// description of feature
6490
(active, $new_feature_name, "$version", Some($tracking_issue_number), $edition)
6591
```
92+
93+
94+
[stability-section]: ./implementing_new_features.md#stability-in-code

src/implementing_new_features.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,8 @@ a new unstable feature:
127127
in the RFC).
128128

129129
3. Add a feature gate declaration to `rustc_feature/src/active.rs`
130-
in the active `declare_features` block:
131-
132-
```rust,ignore
133-
/// description of feature
134-
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number), $edition)
135-
```
136-
137-
where `$edition` has the type `Option<Edition>`, and is typically
138-
just `None`.
139-
140-
For example:
141-
142-
```rust,ignore
143-
/// Allows defining identifiers beyond ASCII.
144-
(active, non_ascii_idents, "1.0.0", Some(55467), None),
145-
```
146-
147-
When added, the current version should be the one for the current nightly.
148-
Once the feature is moved to `accepted.rs`, the version is changed to that nightly version.
130+
in the active `declare_features` block. See [here][add-feature-gate] for
131+
detailed instructions.
149132

150133
4. Prevent usage of the new feature unless the feature gate is set.
151134
You can check it in most places in the compiler using the
@@ -182,3 +165,4 @@ a new unstable feature:
182165
[stability in code]: #stability-in-code
183166
[here]: ./stabilization_guide.md
184167
[tracking issue]: #tracking-issue
168+
[add-feature-gate]: ./feature-gates.md#adding-a-feature-gate

0 commit comments

Comments
 (0)