Skip to content

Commit

Permalink
Fix tidy feature gate error reporting
Browse files Browse the repository at this point in the history
Feature gate definitions were split into multiple files in rust-lang#63824 but
tidy kept reporting the hard-coded path. Now, it shows the full path
to the correct file.
  • Loading branch information
killercup committed Aug 24, 2019
1 parent 4784645 commit 8ca9c7b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) -> CollectedFeatures {
CollectedFeatures { lib: lib_features, lang: features }
}

fn format_features<'a>(features: &'a Features, family: &'a str) -> impl Iterator<Item = String> + 'a {
fn format_features<'a>(
features: &'a Features,
family: &'a str,
) -> impl Iterator<Item = String> + 'a {
features.iter().map(move |(name, feature)| {
format!("{:<32} {:<8} {:<12} {:<8}",
name,
Expand Down Expand Up @@ -228,7 +231,8 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features {
}

fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features {
let contents = t!(fs::read_to_string(base.join("libsyntax/feature_gate").join(file)));
let path = base.join("libsyntax/feature_gate").join(file);
let contents = t!(fs::read_to_string(&path));

// We allow rustc-internal features to omit a tracking issue.
// To make tidy accept omitting a tracking issue, group the list of features
Expand Down Expand Up @@ -259,8 +263,9 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
if in_feature_group {
tidy_error!(
bad,
// ignore-tidy-linelength
"libsyntax/feature_gate.rs:{}: new feature group is started without ending the previous one",
"{}:{}: \
new feature group is started without ending the previous one",
path.display(),
line_number,
);
}
Expand Down Expand Up @@ -289,7 +294,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
Err(err) => {
tidy_error!(
bad,
"libsyntax/feature_gate.rs:{}: failed to parse since: {} ({:?})",
"{}:{}: failed to parse since: {} ({:?})",
path.display(),
line_number,
since_str,
err,
Expand All @@ -301,7 +307,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
if prev_since > since {
tidy_error!(
bad,
"libsyntax/feature_gate.rs:{}: feature {} is not sorted by since",
"{}:{}: feature {} is not sorted by since",
path.display(),
line_number,
name,
);
Expand All @@ -315,7 +322,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
*bad = true;
tidy_error!(
bad,
"libsyntax/feature_gate.rs:{}: no tracking issue for feature {}",
"{}:{}: no tracking issue for feature {}",
path.display(),
line_number,
name,
);
Expand Down

0 comments on commit 8ca9c7b

Please sign in to comment.