|
| 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