Module error_codes

Source
Expand description

Tidy check to ensure error codes are properly documented and tested.

Overview of check:

  1. We create a list of error codes used by the compiler. Error codes are extracted from compiler/rustc_error_codes/src/lib.rs.

  2. We check that the error code has a long-form explanation in compiler/rustc_error_codes/src/error_codes/.

  • The explanation is expected to contain a doctest that fails with the correct error code. (EXEMPT_FROM_DOCTEST currently bypasses this check)
  • Note that other stylistic conventions for markdown files are checked in the style.rs tidy check.
  1. We check that the error code has a UI test in tests/ui/error-codes/.
  • We ensure that there is both a Exxxx.rs file and a corresponding Exxxx.stderr file.
  • We also ensure that the error code is used in the tests.
  • Currently, it is possible to opt-out of this check with the EXEMPTED_FROM_TEST constant.
  1. We check that the error code is actually emitted by the compiler.
  • This is done by searching compiler/ with a regex.

Macros§

verbose_print 🔒

Constants§

ERROR_CODES_PATH 🔒
ERROR_DOCS_PATH 🔒
ERROR_TESTS_PATH 🔒
IGNORE_DOCTEST_CHECK 🔒
IGNORE_UI_TEST_CHECK 🔒

Functions§

check
check_error_codes_docs 🔒
Stage 2: Checks that long-form error code explanations exist and have doctests.
check_error_codes_tests 🔒
check_error_codes_used 🔒
Stage 4: Search compiler/ and ensure that every error code is actually used by the compiler and that no undocumented error codes exist.
check_explanation_has_doctest 🔒
This function returns a tuple indicating whether the provided explanation: a) has a code example, tested or not. b) has a valid doctest
extract_error_codes 🔒
Stage 1: Parses a list of error codes from error_codes.rs.