This commit is contained in:
Ezra Shaw 2023-01-02 16:22:18 +13:00
parent 1f1dd5f3cc
commit b7341db5d8
No known key found for this signature in database
GPG Key ID: 17CD5C2ADAE0D344

View File

@ -173,22 +173,23 @@ fn check_error_codes_docs(
return; return;
} }
let (found_code_example, found_proper_doctest, emit_ignore_warning, emit_no_longer_warning) = check_explanation_has_doctest(&contents, &err_code); let (found_code_example, found_proper_doctest, emit_ignore_warning, emit_no_longer_warning) =
if has_test.2 { check_explanation_has_doctest(&contents, &err_code);
if emit_ignore_warning {
verbose_print!( verbose_print!(
verbose, verbose,
"warning: Error code `{err_code}` uses the ignore header. This should not be used, add the error code to the \ "warning: Error code `{err_code}` uses the ignore header. This should not be used, add the error code to the \
`IGNORE_DOCTEST_CHECK` constant instead." `IGNORE_DOCTEST_CHECK` constant instead."
); );
} }
if has_test.3 { if emit_no_longer_warning {
no_longer_emitted_codes.push(err_code.to_owned()); no_longer_emitted_codes.push(err_code.to_owned());
verbose_print!( verbose_print!(
verbose, verbose,
"warning: Error code `{err_code}` is no longer emitted and should be removed entirely." "warning: Error code `{err_code}` is no longer emitted and should be removed entirely."
); );
} }
if !has_test.0 { if !found_code_example {
verbose_print!( verbose_print!(
verbose, verbose,
"warning: Error code `{err_code}` doesn't have a code example, all error codes are expected to have one \ "warning: Error code `{err_code}` doesn't have a code example, all error codes are expected to have one \
@ -196,15 +197,15 @@ fn check_error_codes_docs(
); );
} }
let test_ignored = IGNORE_DOCTEST_CHECK.contains(&err_code); let test_ignored = IGNORE_DOCTEST_CHECK.contains(&&err_code);
// Check that the explanation has a doctest, and if it shouldn't, that it doesn't // Check that the explanation has a doctest, and if it shouldn't, that it doesn't
if !has_test.1 && !test_ignored { if !found_proper_doctest && !test_ignored {
errors.push(format!( errors.push(format!(
"`{}` doesn't use its own error code in compile_fail example", "`{}` doesn't use its own error code in compile_fail example",
path.display(), path.display(),
)); ));
} else if has_test.1 && test_ignored { } else if found_proper_doctest && test_ignored {
errors.push(format!( errors.push(format!(
"`{}` has a compile_fail doctest with its own error code, it shouldn't \ "`{}` has a compile_fail doctest with its own error code, it shouldn't \
be listed in `IGNORE_DOCTEST_CHECK`", be listed in `IGNORE_DOCTEST_CHECK`",