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