diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-26 23:55:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-26 23:55:49 +0200 |
| commit | b005a89daeee67c10ec05a0affee09472eb3f204 (patch) | |
| tree | 02e4085156b95e1d0a098852ff1be7c9abed4c66 /src/tools | |
| parent | 59fa966a4ddd395ef1b59861d8c8b8152020624e (diff) | |
| parent | 94e8ff4f0b94c788ec9e9a28d3aa6f87062e2966 (diff) | |
| download | rust-b005a89daeee67c10ec05a0affee09472eb3f204.tar.gz rust-b005a89daeee67c10ec05a0affee09472eb3f204.zip | |
Rollup merge of #63855 - killercup:refactor/feature-gates, r=Centril
Refactor feature gates After #63824, this goes a few steps further by - parsing doc comments in the macros to extract descriptions for feature gates, and - introducing a common `Feature` type to replace the tuples used previously to improve readability. The descriptions are not yet used, but I felt like this PR is a useful enough refactoring on its own. r? @Centril
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/tidy/src/features.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 468e5600101..50e9116c778 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -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, @@ -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 @@ -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, ); } @@ -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, @@ -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, ); @@ -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, ); |
