@@ -15,7 +15,7 @@ use std::ffi::OsStr;
15
15
use std:: fmt;
16
16
use std:: fs;
17
17
use std:: num:: NonZeroU32 ;
18
- use std:: path:: Path ;
18
+ use std:: path:: { Path , PathBuf } ;
19
19
20
20
use regex:: Regex ;
21
21
@@ -52,6 +52,8 @@ pub struct Feature {
52
52
pub since : Option < Version > ,
53
53
pub has_gate_test : bool ,
54
54
pub tracking_issue : Option < NonZeroU32 > ,
55
+ pub file : PathBuf ,
56
+ pub line : usize ,
55
57
}
56
58
impl Feature {
57
59
fn tracking_issue_display ( & self ) -> impl fmt:: Display {
@@ -184,23 +186,25 @@ pub fn check(
184
186
. chain ( lib_features. iter ( ) . map ( |feat| ( feat, "lib" ) ) ) ;
185
187
for ( ( feature_name, feature) , kind) in all_features_iter {
186
188
let since = if let Some ( since) = feature. since { since } else { continue } ;
189
+ let file = feature. file . display ( ) ;
190
+ let line = feature. line ;
187
191
if since > version && since != Version :: CurrentPlaceholder {
188
192
tidy_error ! (
189
193
bad,
190
- "The stabilization version {since} of {kind} feature `{feature_name}` is newer than the current {version}"
194
+ "{file}:{line}: The stabilization version {since} of {kind} feature `{feature_name}` is newer than the current {version}"
191
195
) ;
192
196
}
193
197
if channel == "nightly" && since == version {
194
198
tidy_error ! (
195
199
bad,
196
- "The stabilization version {since} of {kind} feature `{feature_name}` is written out but should be {}" ,
200
+ "{file}:{line}: The stabilization version {since} of {kind} feature `{feature_name}` is written out but should be {}" ,
197
201
version:: VERSION_PLACEHOLDER
198
202
) ;
199
203
}
200
204
if channel != "nightly" && since == Version :: CurrentPlaceholder {
201
205
tidy_error ! (
202
206
bad,
203
- "The placeholder use of {kind} feature `{feature_name}` is not allowed on the {channel} channel" ,
207
+ "{file}:{line}: The placeholder use of {kind} feature `{feature_name}` is not allowed on the {channel} channel" ,
204
208
) ;
205
209
}
206
210
}
@@ -433,7 +437,14 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
433
437
) ;
434
438
}
435
439
Entry :: Vacant ( e) => {
436
- e. insert ( Feature { level, since, has_gate_test : false , tracking_issue } ) ;
440
+ e. insert ( Feature {
441
+ level,
442
+ since,
443
+ has_gate_test : false ,
444
+ tracking_issue,
445
+ file : path. to_path_buf ( ) ,
446
+ line : line_number,
447
+ } ) ;
437
448
}
438
449
}
439
450
}
@@ -559,6 +570,8 @@ fn map_lib_features(
559
570
since : None ,
560
571
has_gate_test : false ,
561
572
tracking_issue : find_attr_val ( line, "issue" ) . and_then ( handle_issue_none) ,
573
+ file : file. to_path_buf ( ) ,
574
+ line : i + 1 ,
562
575
} ;
563
576
mf ( Ok ( ( feature_name, feature) ) , file, i + 1 ) ;
564
577
continue ;
@@ -588,7 +601,14 @@ fn map_lib_features(
588
601
} ;
589
602
let tracking_issue = find_attr_val ( line, "issue" ) . and_then ( handle_issue_none) ;
590
603
591
- let feature = Feature { level, since, has_gate_test : false , tracking_issue } ;
604
+ let feature = Feature {
605
+ level,
606
+ since,
607
+ has_gate_test : false ,
608
+ tracking_issue,
609
+ file : file. to_path_buf ( ) ,
610
+ line : i + 1 ,
611
+ } ;
592
612
if line. contains ( ']' ) {
593
613
mf ( Ok ( ( feature_name, feature) ) , file, i + 1 ) ;
594
614
} else {
0 commit comments