rustc_lint - Rust (original) (raw)

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.

pub use builtin::[MissingDoc](builtin/struct.MissingDoc.html "struct rustc_lint::builtin::MissingDoc");

pub use builtin::[SoftLints](builtin/struct.SoftLints.html "struct rustc_lint::builtin::SoftLints");

pub use rustc_session::lint::[Level](enum.Level.html "enum rustc_lint::Level")::*;

async_closures 🔒

async_fn_in_trait 🔒

autorefs 🔒

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 🔒

utils 🔒

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 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 calls check_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

BufferedEarlyLint

Lints that are buffered up early on in the Session before theLintLevels 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.

LintLevelsBuilder

LintStore

Information about the registered lints.

CheckLintNameResult

Level

Setting for how to handle a lint.

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.

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

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 from Session.

LintVec