1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Some lints that are built in to the compiler.
13 //! These are the built-in lints that are emitted direct in the main
14 //! compiler code, rather than using their own custom pass. Those
15 //! lints are all available in `rustc_lint::builtin`.
17 use lint::{LintPass, LateLintPass, LintArray};
22 "constant evaluation detected erroneous expression"
28 "imports that are never used"
32 pub UNUSED_EXTERN_CRATES,
34 "extern crates that are never used"
38 pub UNUSED_QUALIFICATIONS,
40 "detects unnecessarily qualified names"
46 "unrecognized lint attribute"
52 "detect variables which are not used in any way"
56 pub UNUSED_ASSIGNMENTS,
58 "detect assignments that will never be read"
64 "detect unused, unexported items"
70 "detects unreachable code paths"
74 pub UNREACHABLE_PATTERNS,
76 "detects unreachable patterns"
82 "detects macros that were not used"
88 "mass-change the level for lints which produce warnings"
94 "unused or unknown features found in crate-level #[feature] directives"
100 "stable features found in #[feature] directive"
104 pub UNKNOWN_CRATE_TYPES,
106 "unknown crate type found in #[crate_type] directive"
112 "detects trivial casts which could be removed"
116 pub TRIVIAL_NUMERIC_CASTS,
118 "detects trivial casts of numeric types which could be removed"
122 pub PRIVATE_IN_PUBLIC,
124 "detect private items in public interfaces not caught by the old implementation"
128 pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
130 "detect public re-exports of private extern crates"
134 pub INVALID_TYPE_PARAM_DEFAULT,
136 "type parameter default erroneously allowed in invalid location"
140 pub RENAMED_AND_REMOVED_LINTS,
142 "lints that have been renamed or removed"
146 pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
148 "attempt to resolve a trait on an expression whose type cannot be inferred but which \
149 currently defaults to ()"
153 pub SAFE_EXTERN_STATICS,
155 "safe access to extern statics was erroneously allowed"
159 pub SAFE_PACKED_BORROWS,
161 "safe borrows of fields of packed structs were was erroneously allowed"
165 pub PATTERNS_IN_FNS_WITHOUT_BODY,
167 "patterns in functions without body were erroneously allowed"
171 pub LEGACY_DIRECTORY_OWNERSHIP,
173 "non-inline, non-`#[path]` modules (e.g. `mod foo;`) were erroneously allowed in some files \
180 "detects names that resolve to ambiguous glob imports with RFC 1560"
184 pub LEGACY_CONSTRUCTOR_VISIBILITY,
186 "detects use of struct constructors that would be invisible with new visibility rules"
190 pub MISSING_FRAGMENT_SPECIFIER,
192 "detects missing fragment specifiers in unused `macro_rules!` patterns"
196 pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
198 "detects parenthesized generic parameters in type and module names"
202 pub LATE_BOUND_LIFETIME_ARGUMENTS,
204 "detects generic lifetime arguments in path segments with late bound lifetime parameters"
208 pub INCOHERENT_FUNDAMENTAL_IMPLS,
210 "potentially-conflicting impls were erroneously allowed"
216 "detects use of deprecated items"
222 "unnecessary use of an `unsafe` block"
228 "detect mut variables which don't need to be mutable"
234 "detect coercion to !"
238 pub SINGLE_USE_LIFETIME,
240 "detects single use lifetimes"
244 pub TYVAR_BEHIND_RAW_POINTER,
246 "raw pointer to an inference variable"
249 /// Does nothing as a lint pass, but registers some `Lint`s
250 /// which are used by other parts of the compiler.
251 #[derive(Copy, Clone)]
252 pub struct HardwiredLints;
254 impl LintPass for HardwiredLints {
255 fn get_lints(&self) -> LintArray {
258 UNUSED_EXTERN_CRATES,
259 UNUSED_QUALIFICATIONS,
265 UNREACHABLE_PATTERNS,
272 TRIVIAL_NUMERIC_CASTS,
274 PUB_USE_OF_PRIVATE_EXTERN_CRATE,
275 INVALID_TYPE_PARAM_DEFAULT,
277 RENAMED_AND_REMOVED_LINTS,
278 RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
281 PATTERNS_IN_FNS_WITHOUT_BODY,
282 LEGACY_DIRECTORY_OWNERSHIP,
284 LEGACY_CONSTRUCTOR_VISIBILITY,
285 MISSING_FRAGMENT_SPECIFIER,
286 PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
287 LATE_BOUND_LIFETIME_ARGUMENTS,
288 INCOHERENT_FUNDAMENTAL_IMPLS,
294 TYVAR_BEHIND_RAW_POINTER
299 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}