[−][src]Module rustc_lint::builtin

Lints in the Rust compiler.

This contains lints which can feasibly be implemented as their own AST visitor. Also see rustc_session::lint::builtin, which contains the definitions of lints that are emitted directly inside the main compiler.

To add a new lint to rustc, declare it here using declare_lint!(). Then add code to emit the new lint in the appropriate circumstances. You can do that in an existing LintPass if it makes sense, or in a new LintPass, or using Session::add_lint elsewhere in the compiler. Only do the latter if the check can't be written cleanly as a LintPass (also, note that such lints will need to be defined in rustc_session::lint::builtin, not here).

If you define a new EarlyLintPass, you will also need to add it to the add_early_builtin! or add_early_builtin_with_new! invocation in lib.rs. Use the former for unit-like structs and the latter for structs with a pub fn new().

If you define a new LateLintPass, you will also need to add it to the late_lint_methods! invocation in lib.rs.

Structs

AnonymousParameters

Checks for use of anonymous parameters (RFC 1685).

BoxPointers
ClashingExternDeclarations
DeprecatedAttr

Check for use of attributes which have been deprecated.

EllipsisInclusiveRangePatterns
ExplicitOutlivesRequirements
HardwiredLints

Does nothing as a lint pass, but registers some Lints that are used by other parts of the compiler.

IncompleteFeatures

Check for used feature gates in INCOMPLETE_FEATURES in librustc_feature/active.rs.

InvalidNoMangleItems
InvalidValue
KeywordIdents

Check for uses of edition keywords used as an identifier.

MissingCopyImplementations
MissingDebugImplementations
MissingDoc
MutableTransmutes
NonShorthandFieldPatterns
SoftLints

Does nothing as a lint pass, but registers some Lints which are used by other parts of the compiler.

TrivialConstraints

Lint for trait and lifetime bounds that don't depend on type parameters which either do nothing, or stop the item from being used.

TypeAliasBounds

Lint for trait and lifetime bounds in type aliases being mostly ignored. They are relevant when using associated types, but otherwise neither checked at definition site nor enforced at use site.

UnderMacro
UnnameableTestItems
UnreachablePub

Lint for items marked pub that aren't reachable from other crates.

UnsafeCode
UnstableFeatures

Forbids using the #[feature(...)] attribute

UnusedBrokenConst

Lint constants that are erroneous. Without this lint, we might not get any diagnostic if the constant is unused within this crate, even though downstream crates can't use it without producing an error.

UnusedDocComment
WhileTrue

Enums

SymbolName

Differentiate between whether the name for an extern decl came from the link_name attribute or just from declaration itself. This is important because we don't want to report clashes on symbol name if they don't actually clash because one or the other links against a symbol with a different name.

Statics

ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE
AMBIGUOUS_ASSOCIATED_ITEMS
ANONYMOUS_PARAMETERS
ARITHMETIC_OVERFLOW
ASM_SUB_REGISTER
BARE_TRAIT_OBJECTS
BINDINGS_WITH_VARIANT_NAME
BOX_POINTERS
BROKEN_INTRA_DOC_LINKS
CENUM_IMPL_DROP_CAST
CLASHING_EXTERN_DECLARATIONS
COHERENCE_LEAK_CHECK
CONFLICTING_REPR_HINTS
CONST_ERR
DEAD_CODE
DEPRECATED
DEPRECATED_IN_FUTURE
ELIDED_LIFETIMES_IN_PATHS
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS
EXPLICIT_OUTLIVES_REQUIREMENTS
EXPORTED_PRIVATE_DEPENDENCIES
ILLEGAL_FLOATING_POINT_LITERAL_PATTERN
ILL_FORMED_ATTRIBUTE_INPUT
INCOMPLETE_FEATURES
INCOMPLETE_INCLUDE
INDIRECT_STRUCTURAL_MATCH
INLINE_NO_SANITIZE
INVALID_CODEBLOCK_ATTRIBUTES
INVALID_TYPE_PARAM_DEFAULT
INVALID_VALUE
IRREFUTABLE_LET_PATTERNS
KEYWORD_IDENTS
LATE_BOUND_LIFETIME_ARGUMENTS
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS
MACRO_USE_EXTERN_CRATE
META_VARIABLE_MISUSE
MISSING_COPY_IMPLEMENTATIONS
MISSING_CRATE_LEVEL_DOCS
MISSING_DEBUG_IMPLEMENTATIONS
MISSING_DOCS
MISSING_DOC_CODE_EXAMPLES
MUTABLE_BORROW_RESERVATION_CONFLICT
MUTABLE_TRANSMUTES
NON_SHORTHAND_FIELD_PATTERNS
NO_MANGLE_CONST_ITEMS
NO_MANGLE_GENERIC_ITEMS
ORDER_DEPENDENT_TRAIT_OBJECTS
OVERLAPPING_PATTERNS
PATTERNS_IN_FNS_WITHOUT_BODY
PRIVATE_DOC_TESTS
PRIVATE_IN_PUBLIC
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK
PUB_USE_OF_PRIVATE_EXTERN_CRATE
RENAMED_AND_REMOVED_LINTS
SAFE_PACKED_BORROWS
SINGLE_USE_LIFETIMES
SOFT_UNSTABLE
STABLE_FEATURES
TRIVIAL_BOUNDS
TRIVIAL_CASTS
TRIVIAL_NUMERIC_CASTS
TYPE_ALIAS_BOUNDS
TYVAR_BEHIND_RAW_POINTER
UNALIGNED_REFERENCES
UNCONDITIONAL_PANIC
UNCONDITIONAL_RECURSION
UNKNOWN_CRATE_TYPES
UNKNOWN_LINTS
UNNAMEABLE_TEST_ITEMS
UNREACHABLE_CODE
UNREACHABLE_PATTERNS
UNREACHABLE_PUB
UNSAFE_CODE
UNSAFE_OP_IN_UNSAFE_FN
UNSTABLE_FEATURES
UNSTABLE_NAME_COLLISIONS
UNUSED_ASSIGNMENTS
UNUSED_ATTRIBUTES
UNUSED_CRATE_DEPENDENCIES
UNUSED_DOC_COMMENTS
UNUSED_EXTERN_CRATES
UNUSED_FEATURES
UNUSED_IMPORTS
UNUSED_LABELS
UNUSED_LIFETIMES
UNUSED_MACROS
UNUSED_MUT
UNUSED_QUALIFICATIONS
UNUSED_UNSAFE
UNUSED_VARIABLES
WARNINGS
WHERE_CLAUSES_OBJECT_SAFETY
WHILE_TRUE

Functions

check_const
has_doc
lint_deprecated_attr
pierce_parens

Traverse through any amount of parenthesis and return the first non-parens expression.

warn_if_doc