Skip to content

Commit 72eca8f

Browse files
camelidJoshua Nelson
authored and
Joshua Nelson
committed
Document how to modify feature gates
How to remove them and how to rename them. cc <rust-lang/rust#79336 (comment)> cc @varkor
1 parent 5f7bd57 commit 72eca8f

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- [Implementing new features](./implementing_new_features.md)
3939
- [Stability attributes](./stability.md)
4040
- [Stabilizing Features](./stabilization_guide.md)
41+
- [Feature Gates](./feature-gates.md)
4142
- [Coding conventions](./conventions.md)
4243
- [Notification groups](notification-groups/about.md)
4344
- [ARM](notification-groups/arm.md)

src/feature-gates.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Feature Gates
2+
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.
5+
6+
[stability-section]: ./implementing_new_features.md#stability-in-code
7+
8+
9+
## Removing a feature gate
10+
11+
[removing]: #removing-a-feature-gate
12+
13+
To remove a feature gate, follow these steps:
14+
15+
1. Remove the feature gate declaration in `rustc_feature/src/active.rs`.
16+
It will look like this:
17+
18+
```rust,ignore
19+
/// description of feature
20+
(active, $feature_name, "$version", Some($tracking_issue_number), $edition)
21+
```
22+
23+
2. Add a modified version of the feature gate declaration that you just
24+
removed to `rustc_feature/src/removed.rs`:
25+
26+
```rust,ignore
27+
/// description of feature
28+
(removed, $old_feature_name, "$version", Some($tracking_issue_number), $edition,
29+
Some("$why_it_was_removed"))
30+
```
31+
32+
33+
## Renaming a feature gate
34+
35+
[renaming]: #renaming-a-feature-gate
36+
37+
To rename a feature gate, follow these steps (the first two are the same steps
38+
to follow when [removing a feature gate][removing]):
39+
40+
1. Remove the old feature gate declaration in `rustc_feature/src/active.rs`.
41+
It will look like this:
42+
43+
```rust,ignore
44+
/// description of feature
45+
(active, $old_feature_name, "$version", Some($tracking_issue_number), $edition)
46+
```
47+
48+
2. Add a modified version of the old feature gate declaration that you just
49+
removed to `rustc_feature/src/removed.rs`:
50+
51+
```rust,ignore
52+
/// description of feature
53+
/// Renamed to `$new_feature_name`
54+
(removed, $old_feature_name, "$version", Some($tracking_issue_number), $edition,
55+
Some("renamed to `$new_feature_name`"))
56+
```
57+
58+
3. Add a feature gate declaration with the new name to
59+
`rustc_feature/src/active.rs`. It should look very similar to the old
60+
declaration:
61+
62+
```rust,ignore
63+
/// description of feature
64+
(active, $new_feature_name, "$version", Some($tracking_issue_number), $edition)
65+
```

0 commit comments

Comments
 (0)