Skip to content

Commit 24671b7

Browse files
committed
use more paths in error codes
1 parent 9618f64 commit 24671b7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/tools/tidy/src/error_codes.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ pub fn check(root_path: &Path, search_paths: &[&Path], bad: &mut bool) {
6161

6262
/// Stage 1: Parses a list of error codes from `error_codes.rs`.
6363
fn extract_error_codes(root_path: &Path, errors: &mut Vec<String>) -> Vec<String> {
64-
let file = fs::read_to_string(root_path.join(Path::new(ERROR_CODES_PATH)))
65-
.unwrap_or_else(|e| panic!("failed to read `error_codes.rs`: {e}"));
64+
let path = root_path.join(Path::new(ERROR_CODES_PATH));
65+
let file =
66+
fs::read_to_string(&path).unwrap_or_else(|e| panic!("failed to read `{path:?}`: {e}"));
6667

6768
let mut error_codes = Vec::new();
6869
let mut reached_undocumented_codes = false;
@@ -97,7 +98,8 @@ fn extract_error_codes(root_path: &Path, errors: &mut Vec<String>) -> Vec<String
9798
let expected_filename = format!(" include_str!(\"./error_codes/{}.md\"),", err_code);
9899
if expected_filename != split_line.unwrap().1 {
99100
errors.push(format!(
100-
"Error code `{}` expected to reference docs with `{}` but instead found `{}`",
101+
"Error code `{}` expected to reference docs with `{}` but instead found `{}` in \
102+
`compiler/rustc_error_codes/src/error_codes.rs`",
101103
err_code,
102104
expected_filename,
103105
split_line.unwrap().1,
@@ -281,7 +283,7 @@ fn check_error_codes_tests(root_path: &Path, error_codes: &[String], errors: &mu
281283
if IGNORE_UI_TEST_CHECK.contains(&code.as_str()) {
282284
if test_path.exists() {
283285
errors.push(format!(
284-
"Error code `{code}` has a UI test, it shouldn't be listed in `EXEMPTED_FROM_TEST`!"
286+
"Error code `{code}` has a UI test in `src/test/ui/error-codes/{code}.rs`, it shouldn't be listed in `EXEMPTED_FROM_TEST`!"
285287
));
286288
}
287289
continue;
@@ -291,7 +293,7 @@ fn check_error_codes_tests(root_path: &Path, error_codes: &[String], errors: &mu
291293
Ok(file) => file,
292294
Err(err) => {
293295
println!(
294-
"WARNING: Failed to read UI test file for `{code}` but the file exists. The test is assumed to work:\n{err}"
296+
"WARNING: Failed to read UI test file (`{test_path}`) for `{code}` but the file exists. The test is assumed to work:\n{err}"
295297
);
296298
continue;
297299
}

0 commit comments

Comments
 (0)