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