|
1 | 1 | # Feature Gates
|
2 | 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. |
| 3 | +This chapter is intended to provide basic help for adding, removing, and |
| 4 | +modifying feature gates. |
5 | 5 |
|
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. |
7 | 33 |
|
8 | 34 |
|
9 | 35 | ## Removing a feature gate
|
@@ -63,3 +89,6 @@ to follow when [removing a feature gate][removing]):
|
63 | 89 | /// description of feature
|
64 | 90 | (active, $new_feature_name, "$version", Some($tracking_issue_number), $edition)
|
65 | 91 | ```
|
| 92 | + |
| 93 | + |
| 94 | +[stability-section]: ./implementing_new_features.md#stability-in-code |
0 commit comments