Skip to content

Commit 3281621

Browse files
authored
Merge pull request #160 from alexreg/patch-a
Brought section on feature gating up-to-date
2 parents a856101 + b0d3ace commit 3281621

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

feature-guide.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,25 @@ In order to implement a new unstable feature, you need to do the following steps
102102
In the active `declare_features` block:
103103
```
104104
// description of feature
105-
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number))
105+
(active, $feature_name, "$current_nightly_version", Some($tracking_issue_number), $edition)
106106
```
107+
where `$edition` has the type `Option<Edition>`, and is typically just `None`.
107108
108-
For example
109+
For example:
109110
```
110111
// allow '|' at beginning of match arms (RFC 1925)
111-
(active, match_beginning_vert, "1.21.0", Some(44101)),
112+
(active, match_beginning_vert, "1.21.0", Some(44101), None),
112113
```
113114
114-
The current version is not actually important - the important version is when you are *stabilizing* a feature.
115+
The current version is not actually important the important version is when you are *stabilizing* a feature.
115116
4. Prevent usage of the new feature unless the feature gate is set.
116117
You can check it in most places in the compiler using the expression
117118
```
118-
tcx.sess.features.borrow().$feature_name
119+
tcx.sess.features().borrow().$feature_name
119120
```
120121
121122
If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense.
122-
5. Add a test that the feature can't be used without a feature gate, under `src/test/compile-fail/feature-gate-$feature_name.rs`.
123+
5. Add a test to ensure the feature cannot be used without a feature gate, by creating `feature-gate-$feature_name.rs` and `feature-gate-$feature_name.stderr` fiels under the `src/test/ui/feature-gates` directory.
123124
6. Add a section to the unstable book, in `src/doc/unstable-book/src/language-features/$feature_name.md`.
124125
7. Write a lots of tests for the new feature. PRs without tests will not be accepted!
125126
8. Get your PR reviewed and land it. You have now successfully implemented a feature in Rust!

0 commit comments

Comments
 (0)