]> git.lizzy.rs Git - rust.git/blob - src/librustc/lint/builtin.rs
Rollup merge of #29032 - goyox86:goyox86/rusfmting-librustc_bitflags, r=alexcrichton
[rust.git] / src / librustc / lint / builtin.rs
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.
4 //
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.
10
11 //! Some lints that are built in to the compiler.
12 //!
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`.
16
17 use lint::{LintPass, LateLintPass, LintArray};
18
19 declare_lint! {
20     pub UNUSED_IMPORTS,
21     Warn,
22     "imports that are never used"
23 }
24
25 declare_lint! {
26     pub UNUSED_EXTERN_CRATES,
27     Allow,
28     "extern crates that are never used"
29 }
30
31 declare_lint! {
32     pub UNUSED_QUALIFICATIONS,
33     Allow,
34     "detects unnecessarily qualified names"
35 }
36
37 declare_lint! {
38     pub UNKNOWN_LINTS,
39     Warn,
40     "unrecognized lint attribute"
41 }
42
43 declare_lint! {
44     pub UNUSED_VARIABLES,
45     Warn,
46     "detect variables which are not used in any way"
47 }
48
49 declare_lint! {
50     pub UNUSED_ASSIGNMENTS,
51     Warn,
52     "detect assignments that will never be read"
53 }
54
55 declare_lint! {
56     pub DEAD_CODE,
57     Warn,
58     "detect unused, unexported items"
59 }
60
61 declare_lint! {
62     pub UNREACHABLE_CODE,
63     Warn,
64     "detects unreachable code paths"
65 }
66
67 declare_lint! {
68     pub WARNINGS,
69     Warn,
70     "mass-change the level for lints which produce warnings"
71 }
72
73 declare_lint! {
74     pub UNUSED_FEATURES,
75     Warn,
76     "unused or unknown features found in crate-level #[feature] directives"
77 }
78
79 declare_lint! {
80     pub STABLE_FEATURES,
81     Warn,
82     "stable features found in #[feature] directive"
83 }
84
85 declare_lint! {
86     pub UNKNOWN_CRATE_TYPES,
87     Deny,
88     "unknown crate type found in #[crate_type] directive"
89 }
90
91 declare_lint! {
92     pub VARIANT_SIZE_DIFFERENCES,
93     Allow,
94     "detects enums with widely varying variant sizes"
95 }
96
97 declare_lint! {
98     pub FAT_PTR_TRANSMUTES,
99     Allow,
100     "detects transmutes of fat pointers"
101 }
102
103 declare_lint! {
104     pub TRIVIAL_CASTS,
105     Allow,
106     "detects trivial casts which could be removed"
107 }
108
109 declare_lint! {
110     pub TRIVIAL_NUMERIC_CASTS,
111     Allow,
112     "detects trivial casts of numeric types which could be removed"
113 }
114 /// Does nothing as a lint pass, but registers some `Lint`s
115 /// which are used by other parts of the compiler.
116 #[derive(Copy, Clone)]
117 pub struct HardwiredLints;
118
119 impl LintPass for HardwiredLints {
120     fn get_lints(&self) -> LintArray {
121         lint_array!(
122             UNUSED_IMPORTS,
123             UNUSED_EXTERN_CRATES,
124             UNUSED_QUALIFICATIONS,
125             UNKNOWN_LINTS,
126             UNUSED_VARIABLES,
127             UNUSED_ASSIGNMENTS,
128             DEAD_CODE,
129             UNREACHABLE_CODE,
130             WARNINGS,
131             UNUSED_FEATURES,
132             STABLE_FEATURES,
133             UNKNOWN_CRATE_TYPES,
134             VARIANT_SIZE_DIFFERENCES,
135             FAT_PTR_TRANSMUTES,
136             TRIVIAL_CASTS,
137             TRIVIAL_NUMERIC_CASTS
138         )
139     }
140 }
141
142 impl LateLintPass for HardwiredLints {}