Move instructions for adding a feature gate to "Feature Gates"

This commit is contained in:
Camelid 2020-11-23 15:59:15 -08:00 committed by Joshua Nelson
parent 72eca8fcc5
commit 23b04794db
2 changed files with 35 additions and 22 deletions

View File

@ -1,9 +1,35 @@
# Feature Gates # Feature Gates
This chapter is intended to provide basic help for modifying feature gates. See This chapter is intended to provide basic help for adding, removing, and
["Stability in code"][stability-section] for help with *adding* feature gates. modifying feature gates.
[stability-section]: ./implementing_new_features.md#stability-in-code
## Adding a feature gate
See ["Stability in code"][stability-section] for help with adding a new feature;
this section just covers how to add the feature gate *declaration*.
Add a feature gate declaration to `rustc_feature/src/active.rs` in the active
`declare_features` block:
```rust,ignore
/// description of feature
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number), $edition)
```
where `$edition` has the type `Option<Edition>`, and is typically
just `None`.
For example:
```rust,ignore
/// Allows defining identifiers beyond ASCII.
(active, non_ascii_idents, "1.0.0", Some(55467), None),
```
When added, the current version should be the one for the current nightly.
Once the feature is moved to `accepted.rs`, the version is changed to that
nightly version.
## Removing a feature gate ## Removing a feature gate
@ -63,3 +89,6 @@ to follow when [removing a feature gate][removing]):
/// description of feature /// description of feature
(active, $new_feature_name, "$version", Some($tracking_issue_number), $edition) (active, $new_feature_name, "$version", Some($tracking_issue_number), $edition)
``` ```
[stability-section]: ./implementing_new_features.md#stability-in-code

View File

@ -127,25 +127,8 @@ a new unstable feature:
in the RFC). in the RFC).
3. Add a feature gate declaration to `rustc_feature/src/active.rs` 3. Add a feature gate declaration to `rustc_feature/src/active.rs`
in the active `declare_features` block: in the active `declare_features` block. See [here][add-feature-gate] for
detailed instructions.
```rust,ignore
/// description of feature
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number), $edition)
```
where `$edition` has the type `Option<Edition>`, and is typically
just `None`.
For example:
```rust,ignore
/// Allows defining identifiers beyond ASCII.
(active, non_ascii_idents, "1.0.0", Some(55467), None),
```
When added, the current version should be the one for the current nightly.
Once the feature is moved to `accepted.rs`, the version is changed to that nightly version.
4. Prevent usage of the new feature unless the feature gate is set. 4. Prevent usage of the new feature unless the feature gate is set.
You can check it in most places in the compiler using the You can check it in most places in the compiler using the
@ -182,3 +165,4 @@ a new unstable feature:
[stability in code]: #stability-in-code [stability in code]: #stability-in-code
[here]: ./stabilization_guide.md [here]: ./stabilization_guide.md
[tracking issue]: #tracking-issue [tracking issue]: #tracking-issue
[add-feature-gate]: ./feature-gates.md#adding-a-feature-gate