]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
Add a lint about deriving Hash and implementing PartialEq
[rust.git] / src / lib.rs
1 #![feature(plugin_registrar, box_syntax)]
2 #![feature(rustc_private, collections)]
3 #![feature(iter_arith)]
4 #![feature(custom_attribute)]
5 #![allow(unknown_lints)]
6
7 // this only exists to allow the "dogfood" integration test to work
8 #[allow(dead_code)]
9 fn main() {
10     println!("What are you doing? Don't run clippy as an executable");
11 }
12
13 #[macro_use]
14 extern crate syntax;
15 #[macro_use]
16 extern crate rustc;
17 #[macro_use]
18 extern crate rustc_front;
19
20 // Only for the compile time checking of paths
21 extern crate core;
22 extern crate collections;
23
24 // for unicode nfc normalization
25 extern crate unicode_normalization;
26
27 // for semver check in attrs.rs
28 extern crate semver;
29
30 extern crate rustc_plugin;
31
32 use rustc_plugin::Registry;
33
34 #[macro_use]
35 pub mod utils;
36 pub mod consts;
37 pub mod types;
38 pub mod misc;
39 pub mod eq_op;
40 pub mod bit_mask;
41 pub mod ptr_arg;
42 pub mod needless_bool;
43 pub mod approx_const;
44 pub mod eta_reduction;
45 pub mod identity_op;
46 pub mod minmax;
47 pub mod mut_mut;
48 pub mod mut_reference;
49 pub mod len_zero;
50 pub mod attrs;
51 pub mod collapsible_if;
52 pub mod block_in_if_condition;
53 pub mod unicode;
54 pub mod shadow;
55 pub mod strings;
56 pub mod methods;
57 pub mod returns;
58 pub mod lifetimes;
59 pub mod loops;
60 pub mod ranges;
61 pub mod map_clone;
62 pub mod matches;
63 pub mod precedence;
64 pub mod mutex_atomic;
65 pub mod zero_div_zero;
66 pub mod open_options;
67 pub mod needless_features;
68 pub mod needless_update;
69 pub mod no_effect;
70 pub mod temporary_assignment;
71 pub mod transmute;
72 pub mod cyclomatic_complexity;
73 pub mod escape;
74 pub mod entry;
75 pub mod misc_early;
76 pub mod array_indexing;
77 pub mod panic;
78 pub mod derive;
79
80 mod reexport {
81     pub use syntax::ast::{Name, NodeId};
82 }
83
84 #[allow(unused_attributes)]
85 #[plugin_registrar]
86 #[rustfmt_skip]
87 pub fn plugin_registrar(reg: &mut Registry) {
88     reg.register_late_lint_pass(box types::TypePass);
89     reg.register_late_lint_pass(box misc::TopLevelRefPass);
90     reg.register_late_lint_pass(box misc::CmpNan);
91     reg.register_late_lint_pass(box eq_op::EqOp);
92     reg.register_late_lint_pass(box bit_mask::BitMask);
93     reg.register_late_lint_pass(box ptr_arg::PtrArg);
94     reg.register_late_lint_pass(box needless_bool::NeedlessBool);
95     reg.register_late_lint_pass(box approx_const::ApproxConstant);
96     reg.register_late_lint_pass(box misc::FloatCmp);
97     reg.register_early_lint_pass(box precedence::Precedence);
98     reg.register_late_lint_pass(box eta_reduction::EtaPass);
99     reg.register_late_lint_pass(box identity_op::IdentityOp);
100     reg.register_late_lint_pass(box mut_mut::MutMut);
101     reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
102     reg.register_late_lint_pass(box len_zero::LenZero);
103     reg.register_late_lint_pass(box misc::CmpOwned);
104     reg.register_late_lint_pass(box attrs::AttrPass);
105     reg.register_late_lint_pass(box collapsible_if::CollapsibleIf);
106     reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
107     reg.register_late_lint_pass(box misc::ModuloOne);
108     reg.register_late_lint_pass(box unicode::Unicode);
109     reg.register_late_lint_pass(box strings::StringAdd);
110     reg.register_early_lint_pass(box returns::ReturnPass);
111     reg.register_late_lint_pass(box methods::MethodsPass);
112     reg.register_late_lint_pass(box shadow::ShadowPass);
113     reg.register_late_lint_pass(box types::LetPass);
114     reg.register_late_lint_pass(box types::UnitCmp);
115     reg.register_late_lint_pass(box loops::LoopsPass);
116     reg.register_late_lint_pass(box lifetimes::LifetimePass);
117     reg.register_late_lint_pass(box entry::HashMapLint);
118     reg.register_late_lint_pass(box ranges::StepByZero);
119     reg.register_late_lint_pass(box types::CastPass);
120     reg.register_late_lint_pass(box types::TypeComplexityPass);
121     reg.register_late_lint_pass(box matches::MatchPass);
122     reg.register_late_lint_pass(box misc::PatternPass);
123     reg.register_late_lint_pass(box minmax::MinMaxPass);
124     reg.register_late_lint_pass(box open_options::NonSensicalOpenOptions);
125     reg.register_late_lint_pass(box zero_div_zero::ZeroDivZeroPass);
126     reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
127     reg.register_late_lint_pass(box needless_features::NeedlessFeaturesPass);
128     reg.register_late_lint_pass(box needless_update::NeedlessUpdatePass);
129     reg.register_late_lint_pass(box no_effect::NoEffectPass);
130     reg.register_late_lint_pass(box map_clone::MapClonePass);
131     reg.register_late_lint_pass(box temporary_assignment::TemporaryAssignmentPass);
132     reg.register_late_lint_pass(box transmute::UselessTransmute);
133     reg.register_late_lint_pass(box cyclomatic_complexity::CyclomaticComplexity::new(25));
134     reg.register_late_lint_pass(box escape::EscapePass);
135     reg.register_early_lint_pass(box misc_early::MiscEarly);
136     reg.register_late_lint_pass(box misc::UsedUnderscoreBinding);
137     reg.register_late_lint_pass(box array_indexing::ArrayIndexing);
138     reg.register_late_lint_pass(box panic::PanicPass);
139     reg.register_late_lint_pass(box strings::StringLitAsBytes);
140     reg.register_late_lint_pass(box derive::Derive);
141
142
143     reg.register_lint_group("clippy_pedantic", vec![
144         methods::OPTION_UNWRAP_USED,
145         methods::RESULT_UNWRAP_USED,
146         methods::WRONG_PUB_SELF_CONVENTION,
147         mut_mut::MUT_MUT,
148         mutex_atomic::MUTEX_INTEGER,
149         shadow::SHADOW_REUSE,
150         shadow::SHADOW_SAME,
151         shadow::SHADOW_UNRELATED,
152         strings::STRING_ADD,
153         strings::STRING_ADD_ASSIGN,
154         types::CAST_POSSIBLE_TRUNCATION,
155         types::CAST_POSSIBLE_WRAP,
156         types::CAST_PRECISION_LOSS,
157         types::CAST_SIGN_LOSS,
158         unicode::NON_ASCII_LITERAL,
159         unicode::UNICODE_NOT_NFC,
160     ]);
161
162     reg.register_lint_group("clippy", vec![
163         approx_const::APPROX_CONSTANT,
164         array_indexing::OUT_OF_BOUNDS_INDEXING,
165         attrs::DEPRECATED_SEMVER,
166         attrs::INLINE_ALWAYS,
167         bit_mask::BAD_BIT_MASK,
168         bit_mask::INEFFECTIVE_BIT_MASK,
169         block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
170         block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
171         collapsible_if::COLLAPSIBLE_IF,
172         cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
173         derive::DERIVE_HASH_NOT_EQ,
174         entry::MAP_ENTRY,
175         eq_op::EQ_OP,
176         escape::BOXED_LOCAL,
177         eta_reduction::REDUNDANT_CLOSURE,
178         identity_op::IDENTITY_OP,
179         len_zero::LEN_WITHOUT_IS_EMPTY,
180         len_zero::LEN_ZERO,
181         lifetimes::NEEDLESS_LIFETIMES,
182         lifetimes::UNUSED_LIFETIMES,
183         loops::EMPTY_LOOP,
184         loops::EXPLICIT_COUNTER_LOOP,
185         loops::EXPLICIT_ITER_LOOP,
186         loops::ITER_NEXT_LOOP,
187         loops::NEEDLESS_RANGE_LOOP,
188         loops::REVERSE_RANGE_LOOP,
189         loops::UNUSED_COLLECT,
190         loops::WHILE_LET_LOOP,
191         loops::WHILE_LET_ON_ITERATOR,
192         map_clone::MAP_CLONE,
193         matches::MATCH_BOOL,
194         matches::MATCH_OVERLAPPING_ARM,
195         matches::MATCH_REF_PATS,
196         matches::SINGLE_MATCH,
197         methods::CHARS_NEXT_CMP,
198         methods::FILTER_NEXT,
199         methods::OK_EXPECT,
200         methods::OPTION_MAP_UNWRAP_OR,
201         methods::OPTION_MAP_UNWRAP_OR_ELSE,
202         methods::OR_FUN_CALL,
203         methods::SEARCH_IS_SOME,
204         methods::SHOULD_IMPLEMENT_TRAIT,
205         methods::STR_TO_STRING,
206         methods::STRING_TO_STRING,
207         methods::WRONG_SELF_CONVENTION,
208         minmax::MIN_MAX,
209         misc::CMP_NAN,
210         misc::CMP_OWNED,
211         misc::FLOAT_CMP,
212         misc::MODULO_ONE,
213         misc::REDUNDANT_PATTERN,
214         misc::TOPLEVEL_REF_ARG,
215         misc::USED_UNDERSCORE_BINDING,
216         misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
217         misc_early::UNNEEDED_FIELD_PATTERN,
218         mut_reference::UNNECESSARY_MUT_PASSED,
219         mutex_atomic::MUTEX_ATOMIC,
220         needless_bool::NEEDLESS_BOOL,
221         needless_features::UNSTABLE_AS_MUT_SLICE,
222         needless_features::UNSTABLE_AS_SLICE,
223         needless_update::NEEDLESS_UPDATE,
224         no_effect::NO_EFFECT,
225         open_options::NONSENSICAL_OPEN_OPTIONS,
226         panic::PANIC_PARAMS,
227         precedence::PRECEDENCE,
228         ptr_arg::PTR_ARG,
229         ranges::RANGE_STEP_BY_ZERO,
230         ranges::RANGE_ZIP_WITH_LEN,
231         returns::LET_AND_RETURN,
232         returns::NEEDLESS_RETURN,
233         strings::STRING_LIT_AS_BYTES,
234         temporary_assignment::TEMPORARY_ASSIGNMENT,
235         transmute::USELESS_TRANSMUTE,
236         types::BOX_VEC,
237         types::LET_UNIT_VALUE,
238         types::LINKEDLIST,
239         types::TYPE_COMPLEXITY,
240         types::UNIT_CMP,
241         unicode::ZERO_WIDTH_SPACE,
242         zero_div_zero::ZERO_DIVIDED_BY_ZERO,
243     ]);
244 }