From 777951c926820cc20f0047d49091c37e0fbff14e Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 21 Jun 2019 14:58:48 -0400 Subject: [PATCH] Exit early from feature search if no features in file --- src/tools/tidy/src/features.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4bd89f6f0bf22..1841beb1fd116 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -378,7 +378,15 @@ fn map_lib_features(base_src_path: &Path, return; } - let mut becoming_feature: Option<(String, Feature)> = None; + // This is an early exit -- all the attributes we're concerned with must contain this: + // * rustc_const_unstable( + // * unstable( + // * stable( + if !contents.contains("stable(") { + return; + } + + let mut becoming_feature: Option<(&str, Feature)> = None; for (i, line) in contents.lines().enumerate() { macro_rules! err { ($msg:expr) => {{ @@ -457,7 +465,7 @@ fn map_lib_features(base_src_path: &Path, if line.contains(']') { mf(Ok((feature_name, feature)), file, i + 1); } else { - becoming_feature = Some((feature_name.to_owned(), feature)); + becoming_feature = Some((feature_name, feature)); } } });