Skip to content

Commit c755bbb

Browse files
Add checks to ensure the error_codes checker is "clean"
1 parent fbf1b1a commit c755bbb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/tools/tidy/src/error_codes_check.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,18 @@ fn extract_error_codes(
114114
.expect("failed to canonicalize error explanation file path");
115115
match read_to_string(&path) {
116116
Ok(content) => {
117-
if !IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str())
118-
&& !check_if_error_code_is_test_in_explanation(&content, &err_code)
119-
{
117+
let has_test = check_if_error_code_is_test_in_explanation(&content, &err_code);
118+
if !has_test && !IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) {
120119
errors.push(format!(
121120
"`{}` doesn't use its own error code in compile_fail example",
122121
path.display(),
123122
));
123+
} else if has_test && IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) {
124+
errors.push(format!(
125+
"`{}` has a compile_fail example with its own error code, it shouldn't \
126+
be listed in IGNORE_EXPLANATION_CHECK!",
127+
path.display(),
128+
));
124129
}
125130
if check_error_code_explanation(&content, error_codes, err_code) {
126131
errors.push(format!(
@@ -198,6 +203,11 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
198203
for (err_code, nb) in &error_codes {
199204
if !*nb && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
200205
errors.push(format!("Error code {} needs to have at least one UI test!", err_code));
206+
} else if *nb && EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
207+
errors.push(format!(
208+
"Error code {} has a UI test, it shouldn't be listed into EXEMPTED_FROM_TEST!",
209+
err_code
210+
));
201211
}
202212
}
203213
}

0 commit comments

Comments
 (0)