Expand description
Tidy check to ensure error codes are properly documented and tested.
Overview of check:
-
We create a list of error codes used by the compiler. Error codes are extracted from
compiler/rustc_error_codes/src/lib.rs
. -
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.
- 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 correspondingExxxx.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.
- We check that the error code is actually emitted by the compiler.
- This is done by searching
compiler/
with a regex.
Macros§
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
.