Module rustc_lint_defs::builtin
source · Expand description
Some lints that are built in to the compiler.
These are the built-in lints that are emitted direct in the main
compiler code, rather than using their own custom pass. Those
lints are all available in rustc_lint::builtin.
Structs
- Does nothing as a lint pass, but registers some
Lints that are used by other parts of the compiler.
Statics
- The
absolute_paths_not_starting_with_cratelint detects fully qualified paths that start with a module name instead ofcrate,self, or an extern crate name - The
ambiguous_glob_reexportslint detects cases where names re-exported via globs collide. Downstream users trying to use the same name re-exported from multiple globs will receive a warning pointing out redefinition of the same name. - The
arithmetic_overflowlint detects that an arithmetic operation will overflow. - The
asm_sub_registerlint detects using only a subset of a register for inline asm inputs. - The
bad_asm_stylelint detects the use of the.intel_syntaxand.att_syntaxdirectives. - The
bare_trait_objectslint suggests usingdyn Traitfor trait objects. - The
bindings_with_variant_namelint detects pattern bindings with the same name as one of the matched variants. - The
break_with_label_and_looplint detects labeledbreakexpressions with an unlabeled loop as their value expression. - The
byte_slice_in_packed_struct_with_derivelint detects cases where a byte slice field ([u8]) or string slice field (str) is used in apackedstruct that derives one or more built-in traits. - The
coherence_leak_checklint detects conflicting implementations of a trait that are only distinguished by the old leak-check code. - The
conflicting_repr_hintslint detectsreprattributes with conflicting hints. - The
const_evaluatable_uncheckedlint detects a generic constant used in a type. - The
const_item_mutationlint detects attempts to mutate aconstitem. - The
dead_codelint detects unused, unexported items. - The
deprecatedlint detects use of deprecated items. - The
deprecated_cfg_attr_crate_type_namelint detects uses of the#![cfg_attr(..., crate_type = "...")]and#![cfg_attr(..., crate_name = "...")]attributes to conditionally specify the crate type and name in the source code. - The
deprecated_in_futurelint is internal to rustc and should not be used by user code. - The
deprecated_where_clause_locationlint detects when a where clause in front of the equals in an associated type. - The
duplicate_macro_attributeslint detects when a#[test]-like built-in macro attribute is duplicated on an item. This lint may trigger onbench,cfg_eval,testandtest_case. - The
elided_lifetimes_in_pathslint detects the use of hidden lifetime parameters. - The
explicit_outlives_requirementslint detects unnecessary lifetime bounds that can be inferred. - The
exported_private_dependencieslint detects private dependencies that are exposed in a public interface. - The
ffi_unwind_callslint detects calls to foreign functions or function pointers withC-unwindor other FFI-unwind ABIs. - The
forbidden_lint_groupslint detects violations offorbidapplied to a lint group. Due to a bug in the compiler, these used to be overlooked entirely. They now generate a warning. - The
function_item_referenceslint detects function references that are formatted withfmt::Pointeror transmuted. - The
fuzzy_provenance_castslint detects anascast between an integer and a pointer. - The
illegal_floating_point_literal_patternlint detects floating-point literals used in patterns. - The
ill_formed_attribute_inputlint detects ill-formed attribute inputs that were previously accepted and used in practice. - The
implied_bounds_entailmentlint detects cases where the arguments of an impl method have stronger implied bounds than those from the trait method it’s implementing. - The
incomplete_includelint detects the use of theinclude!macro with a file that contains more than one expression. - The
ineffective_unstable_trait_impllint detects#[unstable]attributes which are not used. - The
invalid_alignmentlint detects dereferences of misaligned pointers during constant evaluation. - The
invalid_doc_attributeslint detects when the#[doc(...)]is misused. - The
invalid_macro_export_argumentslint detects cases where#[macro_export]is being used with invalid arguments. - The
invalid_type_param_defaultlint detects type parameter defaults erroneously allowed in an invalid location. - The
irrefutable_let_patternslint detects irrefutable patterns inif lets,while lets, andif letguards. - The
large_assignmentslint detects when objects of large types are being moved around. - The
late_bound_lifetime_argumentslint detects generic lifetime arguments in path segments with late bound lifetime parameters. - The
legacy_derive_helperslint detects derive helper attributes that are used before they are introduced. - The
lossy_provenance_castslint detects anascast between a pointer and an integer. - The
macro_expanded_macro_exports_accessed_by_absolute_pathslint detects macro-expandedmacro_exportmacros from the current crate that cannot be referred to by absolute paths. - The
macro_use_extern_cratelint detects the use of themacro_useattribute. - The
meta_variable_misuselint detects possible meta-variable misuse in macro definitions. - The
missing_abilint detects cases where the ABI is omitted from extern declarations. - The
missing_fragment_specifierlint is issued when an unused pattern in amacro_rules!macro definition has a meta-variable (e.g.$e) that is not followed by a fragment specifier (e.g.:expr). - The
must_not_suspendlint guards against values that shouldn’t be held across suspend points (.await) - The
named_arguments_used_positionallylint detects cases where named arguments are only used positionally in format strings. This usage is valid but potentially very confusing. - The
nontrivial_structural_matchlint detects constants that are used in patterns, whose type is not structural-match and whose initializer body actually uses values that are not structural-match. SoOption<NotStructuralMatch>is ok if the constant is justNone. - The
non_exhaustive_omitted_patternslint detects when a wildcard (_or..) in a pattern for a#[non_exhaustive]struct or enum is reachable. - The
order_dependent_trait_objectslint detects a trait coherency violation that would allow creating two trait impls for the same dynamic trait object involving marker traits. - The
overlapping_range_endpointslint detectsmatcharms that have range patterns that overlap on their endpoints. - The
patterns_in_fns_without_bodylint detectsmutidentifier patterns as a parameter in functions without a body. - The
pointer_structural_matchlint detects pointers used in patterns whose behaviour cannot be relied upon across compiler versions and optimization levels. - The
private_in_publiclint detects private items in public interfaces not caught by the old implementation. - The
proc_macro_back_compatlint detects uses of old versions of certain proc-macro crates, which have hardcoded workarounds in the compiler. - The
proc_macro_derive_resolution_fallbacklint detects proc macro derives using inaccessible names from parent modules. - The
pub_use_of_private_extern_cratelint detects a specific situation of re-exporting a privateextern crate. - The
renamed_and_removed_lintslint detects lints that have been renamed or removed. - The
repr_transparent_external_private_fieldslint detects types marked#[repr(transparent)]that (transitively) contain an external ZST type marked#[non_exhaustive]or containing private fields - The
rust_2021_incompatible_closure_captureslint detects variables that aren’t completely captured in Rust 2021, such that theDroporder of their fields may differ between Rust 2018 and 2021. - The
rust_2021_incompatible_or_patternslint detects usage of old versions of or-patterns. - The
rust_2021_prefixes_incompatible_syntaxlint detects identifiers that will be parsed as a prefix instead in Rust 2021. - The
rust_2021_prelude_collisionslint detects the usage of trait methods which are ambiguous with traits added to the prelude in future editions. - The
semicolon_in_expressions_from_macroslint detects trailing semicolons in macro bodies when the macro is invoked in expression position. This was previous accepted, but is being phased out. - The
single_use_lifetimeslint detects lifetimes that are only used once. - The
soft_unstablelint detects unstable features that were unintentionally allowed on stable. - The
stable_featureslint detects afeatureattribute that has since been made stable. - The
suspicious_auto_trait_implslint checks for potentially incorrect implementations of auto traits. - The
test_unstable_lintlint tests unstable lints and is perma-unstable. - The
text_direction_codepoint_in_commentlint detects Unicode codepoints in comments that change the visual representation of text on screen in a way that does not correspond to their on memory representation. - The
trivial_castslint detects trivial casts which could be replaced with coercion, which may require a temporary variable. - The
trivial_numeric_castslint detects trivial numeric casts of types which could be removed. - The
tyvar_behind_raw_pointerlint detects raw pointer to an inference variable. - The
unconditional_paniclint detects an operation that will cause a panic at runtime. - The
unconditional_recursionlint detects functions that cannot return without calling themselves. - The
undefined_naked_function_abilint detects naked function definitions that either do not specify an ABI or specify the Rust ABI. - The
unexpected_cfgslint detects unexpected conditional compilation conditions. - The
unfulfilled_lint_expectationslint detects lint trigger expectations that have not been fulfilled. - The
uninhabited_staticlint detects uninhabited statics. - The
unknown_crate_typeslint detects an unknown crate type found in acrate_typeattribute. - The
unknown_lintslint detects unrecognized lint attributes. - The
unreachable_codelint detects unreachable code paths. - The
unreachable_patternslint detects unreachable patterns. - The
unsafe_op_in_unsafe_fnlint detects unsafe operations in unsafe functions without an explicit unsafe block. - The
unstable_name_collisionslint detects that you have used a name that the standard library plans to add in the future. - The
unstable_syntax_pre_expansionlint detects the use of unstable syntax that is discarded during attribute expansion. - The
unsupported_calling_conventionslint is output whenever there is a use of thestdcall,fastcall,thiscall,vectorcallcalling conventions (or their unwind variants) on targets that cannot meaningfully be supported for the requested target. - The
unused_assignmentslint detects assignments that will never be read. - The
unused_attributeslint detects attributes that were not used by the compiler. - The
unused_crate_dependencieslint detects crate dependencies that are never used. - The
unused_doc_commentslint detects doc comments that aren’t used byrustdoc. - The
unused_extern_crateslint guards againstextern crateitems that are never used. - The
unused_featureslint detects unused or unknown features found in crate-levelfeatureattributes. - The
unused_importslint detects imports that are never used. - The
unused_labelslint detects labels that are never used. - The
unused_lifetimeslint detects lifetime parameters that are never used. - The
unused_macroslint detects macros that were not used. - The
unused_macro_ruleslint detects macro rules that were not used. - The
unused_mutlint detects mut variables which don’t need to be mutable. - The
unused_qualificationslint detects unnecessarily qualified names. - The
unused_tuple_struct_fieldslint detects fields of tuple structs that are never read. - The
unused_unsafelint detects unnecessary use of anunsafeblock. - The
unused_variableslint detects variables which are not used in any way. - The
useless_deprecatedlint detects deprecation attributes with no effect. - The
warningslint allows you to change the level of other lints which produce warnings.