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 LintPasses 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 calls check_foo once per $pass. Compare with EarlyLintPassObjects, 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 calls check_foo once per $pass. Compare with LateLintPassObjects, 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§

BufferedEarlyLint
Lints that are buffered up early on in the Session before the LintLevels is calculated.
BuiltinCombinedEarlyLintPass
BuiltinCombinedModuleLateLintPass 🔒
BuiltinCombinedPreExpansionLintPass
EarlyContext
Context for lint checking of the AST, after expansion, before lowering to HIR.
FutureIncompatibleInfo
Extra information for a future incompatibility lint.
LateContext
Context for lint checking outside of type inference.
Lint
Specification of a single lint.
LintId
Identifies a lint known to the compiler.
LintStore
Information about the registered lints.

Enums§

CheckLintNameResult
FindLintError
Level
Setting for how to handle a lint.

Statics§

ARRAY_INTO_ITER
The array_into_iter lint detects calling into_iter on arrays.
BOXED_SLICE_INTO_ITER
The boxed_slice_into_iter lint detects calling into_iter on boxed slices.
DEFAULT_LOCALE_RESOURCE
Raw content of Fluent resource for this crate, generated by fluent_messages macro, imported by rustc_driver to include all crates’ resources in one bundle.

Traits§

EarlyCheckNode
Early lints work on different nodes - either on the crate root, or on freshly loaded modules. This trait generalizes over those nodes.
EarlyLintPass
LateLintPass
LintContext
LintPass

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 in rustc_session::lint::builtin).
register_internals 🔒
unerased_lint_store
Extract the LintStore from Session.

Type Aliases§

LintVec