@@ -82,7 +82,7 @@ start the FCP (final-comment-period) process by commenting
82
82
The rest of the team members will review the proposal. If the final
83
83
decision is to stabilize, we proceed to do the actual code modification.
84
84
85
- ## Stabilization PR
85
+ ## Stabilization PR for Language Features
86
86
87
87
Once we have decided to stabilize a feature, we need to have
88
88
a PR that actually makes that stabilization happen. These kinds
@@ -183,6 +183,73 @@ if self.tcx.sess.features.borrow().pub_restricted && something { /* XXX */ }
183
183
if something { /* XXX */ }
184
184
```
185
185
186
+ ## Stabilization PR for Library Features
187
+
188
+ Once we have decided to stabilize a feature, we need to have
189
+ a PR that actually makes that stabilization happen. These kinds
190
+ of PRs are a great way to get involved in Rust, as they're typically
191
+ small -- just updating attributes.
192
+
193
+ Here is a general guide to how to stabilize a feature --
194
+ every feature is different, of course, so some features may
195
+ require steps beyond what this guide talks about.
196
+
197
+ ### Update the stability attributes on the items
198
+
199
+ Library items are marked unstable via the ` #[unstable] ` attribute, like this:
200
+
201
+ ``` rust,ignore
202
+ #[unstable(feature = "total_cmp", issue = "72599")]
203
+ pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering { ... }
204
+ ```
205
+
206
+ You'll need to change that to a ` #[stable] ` attribute with a version:
207
+
208
+ ``` rust,ignore
209
+ #[stable(feature = "total_cmp", since = "1.61.0")]
210
+ ```
211
+
212
+ Note that, the version number is updated to be the version number
213
+ of the stable release where this feature will appear. This can be
214
+ found by consulting [ the forge] ( https://forge.rust-lang.org/#current-release-versions ) .
215
+ Specifically, you'll want to use the version labelled "Nightly".
216
+ That's two versions higher than the current stable release,
217
+ as what's currently in beta will be the next stable release,
218
+ and any change you're making now will be in the one after that.
219
+
220
+ ### Remove feature gates from doctests
221
+
222
+ All the doctests on the items being stabilized will be enabling the unstable feature,
223
+ so now that it's stable those attributes are no longer needed and should be removed.
224
+
225
+ ````` diff
226
+ /// # Examples
227
+ ///
228
+ /// ```
229
+ - /// #![feature(total_cmp)]
230
+ - ///
231
+ /// assert_eq!(0.0_f32.total_cmp(&-0.0), std::cmp::Ordering::Greater);
232
+ /// ```
233
+ `````
234
+
235
+ The most obvious place to find these is on the item itself,
236
+ but it's worth searching the whole library. Often you'll find
237
+ other unstable methods that were also using it in their tests.
238
+
239
+ ### Remove feature gates from the compiler
240
+
241
+ The compiler builds with nightly features allowed, so you may find uses of
242
+ the feature there as well. These also need to be removed.
243
+
244
+ ``` diff
245
+ #![feature(once_cell)]
246
+ #![feature(never_type)]
247
+ - #![feature(total_cmp)]
248
+ #![feature(trusted_step)]
249
+ #![feature(try_blocks)]
250
+ ```
251
+
252
+
186
253
[ rust-lang/rust#32409 ] : https://github.com/rust-lang/rust/issues/32409
187
254
[ `compiler/rustc_feature` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_feature/index.html
188
255
[ The Reference ] : https://github.com/rust-lang/reference
0 commit comments