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 external lint plugins, as is done for Clippy.
See https://rustc-dev-guide.rust-lang.org/diagnostics.html for an overview of how lints are implemented.
§Note
This API is completely unstable and subject to change.
Re-exports§
pub use builtin::MissingDoc;
pub use builtin::SoftLints;
pub use rustc_session::lint::Level::*;
Modules§
- async_
closures 🔒 - async_
fn_ 🔒in_ trait - builtin
- Lints in the Rust compiler.
- context 🔒
- Basic types for managing and implementing lints.
- dangling 🔒
- default_
could_ 🔒be_ derived - deref_
into_ 🔒dyn_ supertrait - drop_
forget_ 🔒useless - early 🔒
- Implementation of the early lint pass.
- enum_
intrinsics_ 🔒non_ enums - errors 🔒
- expect 🔒
- for_
loops_ 🔒over_ fallibles - foreign_
modules 🔒 - hidden_
unicode_ codepoints - if_
let_ 🔒rescope - impl_
trait_ 🔒overcaptures - internal 🔒
- Some lints that are only useful in the compiler or crates that use compiler internals, such as Clippy.
- invalid_
from_ 🔒utf8 - late 🔒
- Implementation of the late lint pass.
- let_
underscore 🔒 - levels 🔒
- lints 🔒
- macro_
expr_ 🔒fragment_ specifier_ 2024_ migration - Migration code for the
expr_fragment_specifier_2024
rule. - map_
unit_ 🔒fn - multiple_
supertrait_ 🔒upcastable - non_
ascii_ 🔒idents - non_
fmt_ 🔒panic - non_
local_ 🔒def - nonstandard_
style 🔒 - noop_
method_ 🔒call - opaque_
hidden_ 🔒inferred_ bound - pass_
by_ 🔒value - passes 🔒
- precedence 🔒
- ptr_
nulls 🔒 - redundant_
semicolon 🔒 - reference_
casting 🔒 - shadowed_
into_ 🔒iter - static_
mut_ 🔒refs - traits 🔒
- types 🔒
- unit_
bindings 🔒 - unqualified_
local_ 🔒imports - unused 🔒
Macros§
- declare_
combined_ early_ lint_ pass - Combines multiple lints passes into a single lint pass, at compile time,
for maximum speed. Each
check_foo
method in$methods
within this pass simply callscheck_foo
once per$pass
. Compare withEarlyLintPassObjects
, which is similar, but combines lint passes at runtime. - declare_
combined_ late_ lint_ pass - Combines multiple lints passes into a single lint pass, at compile time,
for maximum speed. Each
check_foo
method in$methods
within this pass simply callscheck_foo
once per$pass
. Compare withLateLintPassObjects
, which is similar, but combines lint passes at runtime. - early_
lint_ methods - expand_
combined_ early_ lint_ pass_ method - expand_
combined_ early_ lint_ pass_ methods - expand_
combined_ late_ lint_ pass_ method - expand_
combined_ late_ lint_ pass_ methods - late_
lint_ methods
Structs§
- Buffered
Early Lint - Lints that are buffered up early on in the
Session
before theLintLevels
is calculated. - Builtin
Combined Early Lint Pass - Builtin
Combined 🔒Module Late Lint Pass - Builtin
Combined PreExpansion Lint Pass - Early
Context - Context for lint checking of the AST, after expansion, before lowering to HIR.
- Future
Incompatible Info - Extra information for a future incompatibility lint.
- Late
Context - Context for lint checking outside of type inference.
- Lint
- Specification of a single lint.
- LintId
- Identifies a lint known to the compiler.
- Lint
Store - Information about the registered lints.
Enums§
- Check
Lint Name Result - Find
Lint Error - Level
- Setting for how to handle a lint.
Statics§
- ARRAY_
INTO_ ITER - The
array_into_iter
lint detects callinginto_iter
on arrays. - BOXED_
SLICE_ INTO_ ITER - The
boxed_slice_into_iter
lint detects callinginto_iter
on boxed slices. - DEFAULT_
LOCALE_ RESOURCE - Raw content of Fluent resource for this crate, generated by
fluent_messages
macro, imported byrustc_driver
to include all crates’ resources in one bundle.
Traits§
- Early
Check Node - Early lints work on different nodes - either on the crate root, or on freshly loaded modules. This trait generalizes over those nodes.
- Early
Lint Pass - Late
Lint Pass - Lint
Context - Lint
Pass
Functions§
- check_
ast_ node - check_
crate - Performs lint checking on a crate.
- late_
lint_ mod - lint_
mod 🔒 - new_
lint_ store - provide
- register_
builtins 🔒 - Tell the
LintStore
about all the built-in lints (the ones defined in this crate and the ones defined inrustc_session::lint::builtin
). - register_
internals 🔒 - unerased_
lint_ store - Extract the
LintStore
fromSession
.