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 "mass-change the level for lints which produce warnings"
88 "unused or unknown features found in crate-level #[feature] directives"
94 "stable features found in #[feature] directive"
98 pub UNKNOWN_CRATE_TYPES,
100 "unknown crate type found in #[crate_type] directive"
104 pub FAT_PTR_TRANSMUTES,
106 "detects transmutes of fat pointers"
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 INACCESSIBLE_EXTERN_CRATE,
130 "use of inaccessible extern crate erroneously allowed"
134 pub INVALID_TYPE_PARAM_DEFAULT,
136 "type parameter default erroneously allowed in invalid location"
140 pub ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN,
142 "floating-point constants cannot be used in patterns"
146 pub ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN,
148 "constants of struct or enum type can only be used in a pattern if \
149 the struct or enum has `#[derive(PartialEq, Eq)]`"
153 pub RAW_POINTER_DERIVE,
155 "uses of #[derive] with raw pointers are rarely correct"
159 pub HR_LIFETIME_IN_ASSOC_TYPE,
161 "binding for associated type references higher-ranked lifetime \
162 that does not appear in the trait input types"
166 pub OVERLAPPING_INHERENT_IMPLS,
168 "two overlapping inherent impls define an item with the same name were erroneously allowed"
172 pub RENAMED_AND_REMOVED_LINTS,
174 "lints that have been renamed or removed"
178 pub SUPER_OR_SELF_IN_GLOBAL_PATH,
180 "detects super or self keywords at the beginning of global path"
184 pub LIFETIME_UNDERSCORE,
186 "lifetimes or labels named `'_` were erroneously allowed"
190 pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
192 "attempt to resolve a trait on an expression whose type cannot be inferred but which \
193 currently defaults to ()"
197 pub SAFE_EXTERN_STATICS,
199 "safe access to extern statics was erroneously allowed"
203 pub PATTERNS_IN_FNS_WITHOUT_BODY,
205 "patterns in functions without body were erroneously allowed"
209 pub EXTRA_REQUIREMENT_IN_IMPL,
211 "detects extra requirements in impls that were erroneously allowed"
215 pub LEGACY_DIRECTORY_OWNERSHIP,
217 "non-inline, non-`#[path]` modules (e.g. `mod foo;`) were erroneously allowed in some files \
224 "detects names that resolve to ambiguous glob imports with RFC 1560"
228 pub LEGACY_CONSTRUCTOR_VISIBILITY,
230 "detects use of struct constructors that would be invisible with new visibility rules"
234 pub MISSING_FRAGMENT_SPECIFIER,
236 "detects missing fragment specifiers in unused `macro_rules!` patterns"
240 pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
242 "detects parenthesized generic parameters in type and module names"
248 "detects use of deprecated items"
251 /// Does nothing as a lint pass, but registers some `Lint`s
252 /// which are used by other parts of the compiler.
253 #[derive(Copy, Clone)]
254 pub struct HardwiredLints;
256 impl LintPass for HardwiredLints {
257 fn get_lints(&self) -> LintArray {
260 UNUSED_EXTERN_CRATES,
261 UNUSED_QUALIFICATIONS,
267 UNREACHABLE_PATTERNS,
274 TRIVIAL_NUMERIC_CASTS,
276 INACCESSIBLE_EXTERN_CRATE,
277 INVALID_TYPE_PARAM_DEFAULT,
278 ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN,
279 ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN,
282 OVERLAPPING_INHERENT_IMPLS,
283 RENAMED_AND_REMOVED_LINTS,
284 SUPER_OR_SELF_IN_GLOBAL_PATH,
285 HR_LIFETIME_IN_ASSOC_TYPE,
287 RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
289 PATTERNS_IN_FNS_WITHOUT_BODY,
290 EXTRA_REQUIREMENT_IN_IMPL,
291 LEGACY_DIRECTORY_OWNERSHIP,
293 LEGACY_CONSTRUCTOR_VISIBILITY,
294 MISSING_FRAGMENT_SPECIFIER,
295 PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
301 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}