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"
76 "mass-change the level for lints which produce warnings"
82 "unused or unknown features found in crate-level #[feature] directives"
88 "stable features found in #[feature] directive"
92 pub UNKNOWN_CRATE_TYPES
,
94 "unknown crate type found in #[crate_type] directive"
98 pub VARIANT_SIZE_DIFFERENCES
,
100 "detects enums with widely varying variant sizes"
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 MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT
,
142 "unit struct or enum variant erroneously allowed to match via path::ident(..)"
146 pub RAW_POINTER_DERIVE
,
148 "uses of #[derive] with raw pointers are rarely correct"
151 /// Does nothing as a lint pass, but registers some `Lint`s
152 /// which are used by other parts of the compiler.
153 #[derive(Copy, Clone)]
154 pub struct HardwiredLints
;
156 impl LintPass
for HardwiredLints
{
157 fn get_lints(&self) -> LintArray
{
160 UNUSED_EXTERN_CRATES
,
161 UNUSED_QUALIFICATIONS
,
171 VARIANT_SIZE_DIFFERENCES
,
174 TRIVIAL_NUMERIC_CASTS
,
176 INACCESSIBLE_EXTERN_CRATE
,
177 INVALID_TYPE_PARAM_DEFAULT
,
178 MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT
,
185 impl LateLintPass
for HardwiredLints {}