Skip to content

Commit 8ca9c7b

Browse files
author
Pascal Hertleif
committed
Fix tidy feature gate error reporting
Feature gate definitions were split into multiple files in #63824 but tidy kept reporting the hard-coded path. Now, it shows the full path to the correct file.
1 parent 4784645 commit 8ca9c7b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/tools/tidy/src/features.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) -> CollectedFeatures {
176176
CollectedFeatures { lib: lib_features, lang: features }
177177
}
178178

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

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

233237
// We allow rustc-internal features to omit a tracking issue.
234238
// 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
259263
if in_feature_group {
260264
tidy_error!(
261265
bad,
262-
// ignore-tidy-linelength
263-
"libsyntax/feature_gate.rs:{}: new feature group is started without ending the previous one",
266+
"{}:{}: \
267+
new feature group is started without ending the previous one",
268+
path.display(),
264269
line_number,
265270
);
266271
}
@@ -289,7 +294,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
289294
Err(err) => {
290295
tidy_error!(
291296
bad,
292-
"libsyntax/feature_gate.rs:{}: failed to parse since: {} ({:?})",
297+
"{}:{}: failed to parse since: {} ({:?})",
298+
path.display(),
293299
line_number,
294300
since_str,
295301
err,
@@ -301,7 +307,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
301307
if prev_since > since {
302308
tidy_error!(
303309
bad,
304-
"libsyntax/feature_gate.rs:{}: feature {} is not sorted by since",
310+
"{}:{}: feature {} is not sorted by since",
311+
path.display(),
305312
line_number,
306313
name,
307314
);
@@ -315,7 +322,8 @@ fn collect_lang_features_in(base: &Path, file: &str, bad: &mut bool) -> Features
315322
*bad = true;
316323
tidy_error!(
317324
bad,
318-
"libsyntax/feature_gate.rs:{}: no tracking issue for feature {}",
325+
"{}:{}: no tracking issue for feature {}",
326+
path.display(),
319327
line_number,
320328
name,
321329
);

0 commit comments

Comments
 (0)