@@ -112,7 +112,7 @@ pub fn check(
112
112
let file = entry. path ( ) ;
113
113
let filename = file. file_name ( ) . unwrap ( ) . to_string_lossy ( ) ;
114
114
let filen_underscore = filename. replace ( '-' , "_" ) . replace ( ".rs" , "" ) ;
115
- let filename_is_gate_test = test_filen_gate ( & filen_underscore, & mut features) ;
115
+ let filename_gate = test_filen_gate ( & filen_underscore, & mut features) ;
116
116
117
117
for ( i, line) in contents. lines ( ) . enumerate ( ) {
118
118
let mut err = |msg : & str | {
@@ -128,7 +128,7 @@ pub fn check(
128
128
} ;
129
129
match features. get_mut ( feature_name) {
130
130
Some ( f) => {
131
- if filename_is_gate_test {
131
+ if filename_gate == Some ( feature_name ) {
132
132
err ( & format ! (
133
133
"The file is already marked as gate test \
134
134
through its name, no need for a \
@@ -259,18 +259,18 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> {
259
259
r. captures ( line) . and_then ( |c| c. get ( 1 ) ) . map ( |m| m. as_str ( ) )
260
260
}
261
261
262
- fn test_filen_gate ( filen_underscore : & str , features : & mut Features ) -> bool {
262
+ fn test_filen_gate < ' f > ( filen_underscore : & ' f str , features : & mut Features ) -> Option < & ' f str > {
263
263
let prefix = "feature_gate_" ;
264
- if filen_underscore. starts_with ( prefix) {
264
+ if let Some ( suffix ) = filen_underscore. strip_prefix ( prefix) {
265
265
for ( n, f) in features. iter_mut ( ) {
266
266
// Equivalent to filen_underscore == format!("feature_gate_{n}")
267
- if & filen_underscore [ prefix . len ( ) .. ] == n {
267
+ if suffix == n {
268
268
f. has_gate_test = true ;
269
- return true ;
269
+ return Some ( suffix ) ;
270
270
}
271
271
}
272
272
}
273
- false
273
+ None
274
274
}
275
275
276
276
pub fn collect_lang_features ( base_compiler_path : & Path , bad : & mut bool ) -> Features {
0 commit comments