Skip to content

Commit 777951c

Browse files
Exit early from feature search if no features in file
1 parent 6c5c78d commit 777951c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: src/tools/tidy/src/features.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,15 @@ fn map_lib_features(base_src_path: &Path,
378378
return;
379379
}
380380

381-
let mut becoming_feature: Option<(String, Feature)> = None;
381+
// This is an early exit -- all the attributes we're concerned with must contain this:
382+
// * rustc_const_unstable(
383+
// * unstable(
384+
// * stable(
385+
if !contents.contains("stable(") {
386+
return;
387+
}
388+
389+
let mut becoming_feature: Option<(&str, Feature)> = None;
382390
for (i, line) in contents.lines().enumerate() {
383391
macro_rules! err {
384392
($msg:expr) => {{
@@ -457,7 +465,7 @@ fn map_lib_features(base_src_path: &Path,
457465
if line.contains(']') {
458466
mf(Ok((feature_name, feature)), file, i + 1);
459467
} else {
460-
becoming_feature = Some((feature_name.to_owned(), feature));
468+
becoming_feature = Some((feature_name, feature));
461469
}
462470
}
463471
});

0 commit comments

Comments
 (0)