Crate rustc_lint
source ·Expand description
Lints, aka compiler warnings.
A ‘lint’ check is a kind of miscellaneous constraint that a user might want to enforce, but might reasonably want to permit as well, on a module-by-module basis. They contrast with static constraints enforced by other phases of the compiler, which are generally required to hold in order to compile the program at all.
Most lints can be written as LintPass instances. These run after
all other analyses. The LintPass
es built into rustc are defined
within rustc_session::lint::builtin,
which has further comments on how to add such a lint.
rustc can also load user-defined lint plugins via the plugin mechanism.
Some of rustc’s lints are defined elsewhere in the compiler and work by
calling add_lint()
on the overall Session
object. This works when
it happens before the main lint pass, which emits the lints stored by
add_lint()
. To emit lints after the main lint pass (from codegen, for
example) requires more effort. See emit_lint
and GatherNodeLevels
in context.rs
.
Some code also exists in rustc_session::lint, rustc_middle::lint.
Note
This API is completely unstable and subject to change.
Re-exports
Modules
Macros
check_foo
method in $methods
within this pass
simply calls check_foo
once per $pass
. Compare with
EarlyLintPassObjects
, which is similar, but combines lint passes at
runtime.check_foo
method in $methods
within this pass
simply calls check_foo
once per $pass
. Compare with
LateLintPassObjects
, which is similar, but combines lint passes at
runtime.Structs
Session
before the
LintLevels
is calculated.Enums
Statics
array_into_iter
lint detects calling into_iter
on arrays.Traits
Functions
LintStore
about all the built-in lints (the ones
defined in this crate and the ones defined in
rustc_session::lint::builtin
).LintStore
from the query context.
This function exists because we’ve erased LintStore
as dyn Any
in the context.