Skip to content

Commit 22a702d

Browse files
Add check on constant to ensure it's up to date
1 parent 23e5ed1 commit 22a702d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/tools/tidy/src/error_codes_check.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use regex::Regex;
1111

1212
// A few of those error codes can't be tested but all the others can and *should* be tested!
1313
const EXEMPTED_FROM_TEST: &[&str] = &[
14-
"E0227", "E0279", "E0280", "E0313", "E0314", "E0315", "E0377", "E0461", "E0462", "E0464",
15-
"E0465", "E0473", "E0474", "E0475", "E0476", "E0479", "E0480", "E0481", "E0482", "E0483",
16-
"E0484", "E0485", "E0486", "E0487", "E0488", "E0489", "E0514", "E0519", "E0523", "E0553",
17-
"E0554", "E0570", "E0629", "E0630", "E0640", "E0717", "E0729",
14+
"E0227", "E0279", "E0280", "E0313", "E0315", "E0377", "E0461", "E0462", "E0464", "E0465",
15+
"E0473", "E0474", "E0475", "E0476", "E0479", "E0480", "E0481", "E0482", "E0483", "E0484",
16+
"E0485", "E0486", "E0487", "E0488", "E0489", "E0514", "E0519", "E0523", "E0554", "E0570",
17+
"E0640", "E0717", "E0729",
1818
];
1919

2020
// Some error codes don't have any tests apparently...
@@ -293,6 +293,27 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
293293
}
294294
}
295295
}
296+
if errors.is_empty() {
297+
// Checking if local constants need to be cleaned.
298+
for err_code in EXEMPTED_FROM_TEST {
299+
match error_codes.get(err_code.to_owned()) {
300+
Some(status) => {
301+
if status.has_test {
302+
errors.push(format!(
303+
"{} error code has a test and therefore should be \
304+
removed from the `EXEMPTED_FROM_TEST` constant",
305+
err_code
306+
));
307+
}
308+
}
309+
None => errors.push(format!(
310+
"{} error code isn't used anymore and therefore should be removed \
311+
from `EXEMPTED_FROM_TEST` constant",
312+
err_code
313+
)),
314+
}
315+
}
316+
}
296317
errors.sort();
297318
for err in &errors {
298319
eprintln!("{}", err);

0 commit comments

Comments
 (0)