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.

When removing a lint, make sure to also add a call to register_removed in compiler/rustc_lint/src/lib.rs.

Structs§

Statics§

  • The absolute_paths_not_starting_with_crate lint detects fully qualified paths that start with a module name instead of crate, self, or an extern crate name
  • The ambiguous_associated_items lint detects ambiguity between associated items and enum variants.
  • The ambiguous_glob_imports lint detects glob imports that should report ambiguity errors, but previously didn’t do that due to rustc bugs.
  • The ambiguous_glob_reexports lint 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_overflow lint detects that an arithmetic operation will overflow.
  • The asm_sub_register lint detects using only a subset of a register for inline asm inputs.
  • The bad_asm_style lint detects the use of the .intel_syntax and .att_syntax directives.
  • The bare_trait_objects lint suggests using dyn Trait for trait objects.
  • The bindings_with_variant_name lint detects pattern bindings with the same name as one of the matched variants.
  • The break_with_label_and_loop lint detects labeled break expressions with an unlabeled loop as their value expression.
  • The byte_slice_in_packed_struct_with_derive lint detects cases where a byte slice field ([u8]) or string slice field (str) is used in a packed struct that derives one or more built-in traits.
  • The cenum_impl_drop_cast lint detects an as cast of a field-less enum that implements Drop.
  • The coherence_leak_check lint detects conflicting implementations of a trait that are only distinguished by the old leak-check code.
  • The conflicting_repr_hints lint detects repr attributes with conflicting hints.
  • The const_evaluatable_unchecked lint detects a generic constant used in a type.
  • The const_item_mutation lint detects attempts to mutate a const item.
  • The dead_code lint detects unused, unexported items.
  • The deprecated lint detects use of deprecated items.
  • The deprecated_cfg_attr_crate_type_name lint 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_future lint is internal to rustc and should not be used by user code.
  • The deprecated_where_clause_location lint detects when a where clause in front of the equals in an associated type.
  • The duplicate_macro_attributes lint detects when a #[test]-like built-in macro attribute is duplicated on an item. This lint may trigger on bench, cfg_eval, test and test_case.
  • The elided_lifetimes_in_associated_constant lint detects elided lifetimes that were erroneously allowed in associated constants.
  • The elided_lifetimes_in_paths lint detects the use of hidden lifetime parameters.
  • The explicit_outlives_requirements lint detects unnecessary lifetime bounds that can be inferred.
  • The exported_private_dependencies lint detects private dependencies that are exposed in a public interface.
  • The ffi_unwind_calls lint detects calls to foreign functions or function pointers with C-unwind or other FFI-unwind ABIs.
  • The forbidden_lint_groups lint detects violations of forbid applied 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_references lint detects function references that are formatted with fmt::Pointer or transmuted.
  • The fuzzy_provenance_casts lint detects an as cast between an integer and a pointer.
  • The hidden_glob_reexports lint detects cases where glob re-export items are shadowed by private items.
  • The ill_formed_attribute_input lint detects ill-formed attribute inputs that were previously accepted and used in practice.
  • The incomplete_include lint detects the use of the include! macro with a file that contains more than one expression.
  • The indirect_structural_match lint detects a const in a pattern that manually implements PartialEq and Eq.
  • The ineffective_unstable_trait_impl lint detects #[unstable] attributes which are not used.
  • The inline_no_sanitize lint detects incompatible use of #[inline(always)] and #[no_sanitize(...)].
  • The invalid_doc_attributes lint detects when the #[doc(...)] is misused.
  • The invalid_macro_export_arguments lint detects cases where #[macro_export] is being used with invalid arguments.
  • The invalid_type_param_default lint detects type parameter defaults erroneously allowed in an invalid location.
  • The irrefutable_let_patterns lint detects irrefutable patterns in if lets, while lets, and if let guards.
  • The large_assignments lint detects when objects of large types are being moved around.
  • The late_bound_lifetime_arguments lint detects generic lifetime arguments in path segments with late bound lifetime parameters.
  • The legacy_derive_helpers lint detects derive helper attributes that are used before they are introduced.
  • The long_running_const_eval lint is emitted when const eval is running for a long time to ensure rustc terminates even if you accidentally wrote an infinite loop.
  • The lossy_provenance_casts lint detects an as cast between a pointer and an integer.
  • The macro_expanded_macro_exports_accessed_by_absolute_paths lint detects macro-expanded macro_export macros from the current crate that cannot be referred to by absolute paths.
  • The macro_use_extern_crate lint detects the use of the macro_use attribute.
  • The meta_variable_misuse lint detects possible meta-variable misuse in macro definitions.
  • The missing_abi lint detects cases where the ABI is omitted from extern declarations.
  • The missing_fragment_specifier lint is issued when an unused pattern in a macro_rules! macro definition has a meta-variable (e.g. $e) that is not followed by a fragment specifier (e.g. :expr).
  • The must_not_suspend lint guards against values that shouldn’t be held across suspend points (.await)
  • The named_arguments_used_positionally lint detects cases where named arguments are only used positionally in format strings. This usage is valid but potentially very confusing.
  • The non_exhaustive_omitted_patterns lint aims to help consumers of a #[non_exhaustive] struct or enum who want to match all of its fields/variants explicitly.
  • The order_dependent_trait_objects lint detects a trait coherency violation that would allow creating two trait impls for the same dynamic trait object involving marker traits.
  • The overlapping_range_endpoints lint detects match arms that have range patterns that overlap on their endpoints.
  • The patterns_in_fns_without_body lint detects mut identifier patterns as a parameter in functions without a body.
  • The pointer_structural_match lint detects pointers used in patterns whose behaviour cannot be relied upon across compiler versions and optimization levels.
  • The private_bounds lint detects types in a secondary interface of an item, that are more private than the item itself. Secondary interface of an item consists of bounds on generic parameters and where clauses, including supertraits for trait items.
  • The private_interfaces lint detects types in a primary interface of an item, that are more private than the item itself. Primary interface of an item is all its interface except for bounds on generic parameters and where clauses.
  • The private_macro_use lint detects private macros that are imported with #[macro_use].
  • The proc_macro_back_compat lint detects uses of old versions of certain proc-macro crates, which have hardcoded workarounds in the compiler.
  • The proc_macro_derive_resolution_fallback lint detects proc macro derives using inaccessible names from parent modules.
  • The pub_use_of_private_extern_crate lint detects a specific situation of re-exporting a private extern crate.
  • The refining_impl_trait lint detects usages of return-position impl traits in trait signatures which are refined by implementations.
  • The renamed_and_removed_lints lint detects lints that have been renamed or removed.
  • The repr_transparent_external_private_fields lint detects types marked #[repr(transparent)] that (transitively) contain an external ZST type marked #[non_exhaustive] or containing private fields
  • The rust_2021_incompatible_closure_captures lint detects variables that aren’t completely captured in Rust 2021, such that the Drop order of their fields may differ between Rust 2018 and 2021.
  • The rust_2021_incompatible_or_patterns lint detects usage of old versions of or-patterns.
  • The rust_2021_prefixes_incompatible_syntax lint detects identifiers that will be parsed as a prefix instead in Rust 2021.
  • The rust_2021_prelude_collisions lint detects the usage of trait methods which are ambiguous with traits added to the prelude in future editions.
  • The semicolon_in_expressions_from_macros lint 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_lifetimes lint detects lifetimes that are only used once.
  • The soft_unstable lint detects unstable features that were unintentionally allowed on stable.
  • The stable_features lint detects a feature attribute that has since been made stable.
  • The static_mut_refs lint checks for shared or mutable references of mutable static inside unsafe blocks and unsafe functions.
  • The test_unstable_lint lint tests unstable lints and is perma-unstable.
  • The text_direction_codepoint_in_comment lint 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_casts lint detects trivial casts which could be replaced with coercion, which may require a temporary variable.
  • The trivial_numeric_casts lint detects trivial numeric casts of types which could be removed.
  • The tyvar_behind_raw_pointer lint detects raw pointer to an inference variable.
  • The unconditional_panic lint detects an operation that will cause a panic at runtime.
  • The unconditional_recursion lint detects functions that cannot return without calling themselves.
  • The undefined_naked_function_abi lint detects naked function definitions that either do not specify an ABI or specify the Rust ABI.
  • The unexpected_cfgs lint detects unexpected conditional compilation conditions.
  • The unfulfilled_lint_expectations lint detects lint trigger expectations that have not been fulfilled.
  • The uninhabited_static lint detects uninhabited statics.
  • The unknown_crate_types lint detects an unknown crate type found in a crate_type attribute.
  • The unknown_lints lint detects unrecognized lint attributes.
  • The unknown_or_malformed_diagnostic_attributes lint detects unrecognized or otherwise malformed diagnostic attributes.
  • The unnameable_test_items lint detects #[test] functions that are not able to be run by the test harness because they are in a position where they are not nameable.
  • The unnameable_types lint detects types for which you can get objects of that type, but cannot name the type itself.
  • The unreachable_code lint detects unreachable code paths.
  • The unreachable_patterns lint detects unreachable patterns.
  • The unsafe_op_in_unsafe_fn lint detects unsafe operations in unsafe functions without an explicit unsafe block.
  • The unstable_name_collisions lint detects that you have used a name that the standard library plans to add in the future.
  • The unstable_syntax_pre_expansion lint detects the use of unstable syntax that is discarded during attribute expansion.
  • The unsupported_calling_conventions lint is output whenever there is a use of the stdcall, fastcall, thiscall, vectorcall calling conventions (or their unwind variants) on targets that cannot meaningfully be supported for the requested target.
  • The unused_assignments lint detects assignments that will never be read.
  • The unused_associated_type_bounds lint is emitted when an associated type bound is added to a trait object, but the associated type has a where Self: Sized bound, and is thus unavailable on the trait object anyway.
  • The unused_attributes lint detects attributes that were not used by the compiler.
  • The unused_crate_dependencies lint detects crate dependencies that are never used.
  • The unused_doc_comments lint detects doc comments that aren’t used by rustdoc.
  • The unused_extern_crates lint guards against extern crate items that are never used.
  • The unused_features lint detects unused or unknown features found in crate-level feature attributes.
  • The unused_imports lint detects imports that are never used.
  • The unused_labels lint detects labels that are never used.
  • The unused_lifetimes lint detects lifetime parameters that are never used.
  • The unused_macros lint detects macros that were not used.
  • The unused_macro_rules lint detects macro rules that were not used.
  • The unused_mut lint detects mut variables which don’t need to be mutable.
  • The unused_qualifications lint detects unnecessarily qualified names.
  • The unused_unsafe lint detects unnecessary use of an unsafe block.
  • The unused_variables lint detects variables which are not used in any way.
  • The useless_deprecated lint detects deprecation attributes with no effect.
  • The warnings lint allows you to change the level of other lints which produce warnings.
  • The where_clauses_object_safety lint detects for object safety of where clauses.
  • The writes_through_immutable_pointer lint detects writes through pointers derived from shared references.