Module rustc_lint::builtin[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Lints in the Rust compiler.

This contains lints which can feasibly be implemented as their own AST visitor. Also see rustc::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::lint::builtin, not here).

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

Re-exports

use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::cfg;
use rustc::ty::subst::Substs;
use rustc::ty;
use rustc::ty::Ty;
use rustc::traits;
use rustc::hir::map as hir_map;
use util::nodemap::NodeSet;
use lint::LateContext;
use lint::LintContext;
use lint::LintArray;
use lint::LintPass;
use lint::LateLintPass;
use lint::EarlyLintPass;
use lint::EarlyContext;
use std::collections::HashSet;
use syntax::ast;
use syntax::attr;
use syntax::feature_gate::AttributeGate;
use syntax::feature_gate::AttributeType;
use syntax::feature_gate::Stability;
use syntax::feature_gate::deprecated_attributes;
use syntax_pos::BytePos;
use syntax_pos::Span;
use syntax_pos::SyntaxContext;
use syntax::symbol::keywords;
use syntax::errors::Applicability;
use syntax::errors::DiagnosticBuilder;
use rustc::hir;
use rustc::hir::PatKind;
use rustc::hir::intravisit::FnKind;
use bad_style::MethodLateContext;
use bad_style::method_context;
pub use lint::builtin::*;

Structs

AnonymousParameters [
Experimental
]

Checks for use of anonymous parameters (RFC 1685)

BoxPointers [
Experimental
]
DeprecatedAttr [
Experimental
]

Checks for use of attributes which have been deprecated.

InvalidNoMangleItems [
Experimental
]
MissingCopyImplementations [
Experimental
]
MissingDebugImplementations [
Experimental
]
MissingDoc [
Experimental
]
MutableTransmutes [
Experimental
]
NonShorthandFieldPatterns [
Experimental
]
PluginAsLibrary [
Experimental
]
TypeAliasBounds [
Experimental
]

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.

UnconditionalRecursion [
Experimental
]
UnionsWithDropFields [
Experimental
]

Lint for unions that contain fields with possibly non-trivial destructors.

UnreachablePub [
Experimental
]

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

UnsafeCode [
Experimental
]
UnstableFeatures [
Experimental
]

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

UnusedBrokenConst [
Experimental
]

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.

UnusedBrokenConstVisitor [
Experimental
]
UnusedDocComment [
Experimental
]
WhileTrue [
Experimental
]

Statics

ANONYMOUS_PARAMETERS [
Experimental
]
BOX_POINTERS [
Experimental
]
MISSING_COPY_IMPLEMENTATIONS [
Experimental
]
MISSING_DEBUG_IMPLEMENTATIONS [
Experimental
]
MISSING_DOCS [
Experimental
]
MUTABLE_TRANSMUTES [
Experimental
]
NON_SHORTHAND_FIELD_PATTERNS [
Experimental
]
NO_MANGLE_CONST_ITEMS [
Experimental
]
NO_MANGLE_GENERIC_ITEMS [
Experimental
]
PLUGIN_AS_LIBRARY [
Experimental
]
PRIVATE_NO_MANGLE_FNS [
Experimental
]
PRIVATE_NO_MANGLE_STATICS [
Experimental
]
TYPE_ALIAS_BOUNDS [
Experimental
]
UNCONDITIONAL_RECURSION [
Experimental
]
UNIONS_WITH_DROP_FIELDS [
Experimental
]
UNREACHABLE_PUB [
Experimental
]
UNSAFE_CODE [
Experimental
]
UNSTABLE_FEATURES [
Experimental
]
UNUSED_DOC_COMMENTS [
Experimental
]
WHILE_TRUE [
Experimental
]

Functions

check_const [
Experimental
]