7
7
//! * Library features have at most one stability level.
8
8
//! * Library features have at most one `since` value.
9
9
//! * All unstable lang features have tests to ensure they are actually unstable.
10
+ //! * Language features in a group are sorted by `since` value.
10
11
11
12
use std:: collections:: HashMap ;
12
13
use std:: fmt;
@@ -198,6 +199,7 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
198
199
let mut next_feature_omits_tracking_issue = false ;
199
200
200
201
let mut next_feature_group = None ;
202
+ let mut prev_since = None ;
201
203
202
204
contents. lines ( ) . zip ( 1 ..)
203
205
. filter_map ( |( line, line_number) | {
@@ -219,9 +221,11 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
219
221
if line. starts_with ( FEATURE_GROUP_START_PREFIX ) {
220
222
let group = line. trim_start_matches ( FEATURE_GROUP_START_PREFIX ) . trim ( ) ;
221
223
next_feature_group = Some ( group. to_owned ( ) ) ;
224
+ prev_since = None ;
222
225
return None ;
223
226
} else if line. starts_with ( FEATURE_GROUP_END_PREFIX ) {
224
227
next_feature_group = None ;
228
+ prev_since = None ;
225
229
return None ;
226
230
}
227
231
@@ -233,6 +237,7 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
233
237
_ => return None ,
234
238
} ;
235
239
let name = parts. next ( ) . unwrap ( ) . trim ( ) ;
240
+
236
241
let since_str = parts. next ( ) . unwrap ( ) . trim ( ) . trim_matches ( '"' ) ;
237
242
let since = match since_str. parse ( ) {
238
243
Ok ( since) => Some ( since) ,
@@ -247,6 +252,18 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
247
252
None
248
253
}
249
254
} ;
255
+ if next_feature_group. is_some ( ) {
256
+ if prev_since > since {
257
+ tidy_error ! (
258
+ bad,
259
+ "libsyntax/feature_gate.rs:{}: feature {} is not sorted by since" ,
260
+ line_number,
261
+ name,
262
+ ) ;
263
+ }
264
+ prev_since = since. clone ( ) ;
265
+ }
266
+
250
267
let issue_str = parts. next ( ) . unwrap ( ) . trim ( ) ;
251
268
let tracking_issue = if issue_str. starts_with ( "None" ) {
252
269
if level == Status :: Unstable && !next_feature_omits_tracking_issue {
0 commit comments