]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/lib.rs
Merge pull request #2672 from ysimonson/multiple-crate-versions
[rust.git] / clippy_lints / src / lib.rs
1 // error-pattern:cargo-clippy
2
3 #![feature(box_syntax)]
4 #![feature(custom_attribute)]
5 #![feature(rustc_private)]
6 #![feature(slice_patterns)]
7 #![feature(stmt_expr_attributes)]
8 #![feature(conservative_impl_trait)]
9 #![feature(range_contains)]
10 #![feature(macro_vis_matcher)]
11 #![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)]
12 #![recursion_limit = "256"]
13 // FIXME(mark-i-m) remove after i128 stablization merges
14 #![allow(stable_features)]
15 #![feature(i128, i128_type)]
16 #![feature(iterator_find_map)]
17
18
19 extern crate cargo_metadata;
20 #[macro_use]
21 extern crate rustc;
22 extern crate rustc_typeck;
23 extern crate rustc_target;
24 extern crate syntax;
25 extern crate syntax_pos;
26
27 extern crate toml;
28
29 // for unicode nfc normalization
30
31 extern crate unicode_normalization;
32
33 // for semver check in attrs.rs
34
35 extern crate semver;
36
37 // for regex checking
38
39 extern crate regex_syntax;
40
41 // for finding minimal boolean expressions
42
43 extern crate quine_mc_cluskey;
44
45 extern crate rustc_const_math;
46 extern crate rustc_errors;
47 extern crate rustc_plugin;
48
49 #[macro_use]
50 extern crate matches as matches_macro;
51
52 extern crate serde;
53 #[macro_use]
54 extern crate serde_derive;
55
56 #[macro_use]
57 extern crate lazy_static;
58
59 extern crate itertools;
60 extern crate pulldown_cmark;
61 extern crate url;
62
63 #[macro_use]
64 extern crate if_chain;
65
66 macro_rules! declare_clippy_lint {
67     { pub $name:tt, style, $description:tt } => {
68         declare_lint! { pub $name, Warn, $description }
69     };
70     { pub $name:tt, correctness, $description:tt } => {
71         declare_lint! { pub $name, Deny, $description }
72     };
73     { pub $name:tt, complexity, $description:tt } => {
74         declare_lint! { pub $name, Warn, $description }
75     };
76     { pub $name:tt, perf, $description:tt } => {
77         declare_lint! { pub $name, Warn, $description }
78     };
79     { pub $name:tt, pedantic, $description:tt } => {
80         declare_lint! { pub $name, Allow, $description }
81     };
82     { pub $name:tt, restriction, $description:tt } => {
83         declare_lint! { pub $name, Allow, $description }
84     };
85     { pub $name:tt, cargo, $description:tt } => {
86         declare_lint! { pub $name, Allow, $description }
87     };
88     { pub $name:tt, nursery, $description:tt } => {
89         declare_lint! { pub $name, Allow, $description }
90     };
91     { pub $name:tt, internal, $description:tt } => {
92         declare_lint! { pub $name, Allow, $description }
93     };
94     { pub $name:tt, internal_warn, $description:tt } => {
95         declare_lint! { pub $name, Warn, $description }
96     };
97 }
98
99 pub mod consts;
100 #[macro_use]
101 pub mod utils;
102
103 // begin lints modules, do not remove this comment, it’s used in `update_lints`
104 pub mod approx_const;
105 pub mod arithmetic;
106 pub mod array_indexing;
107 pub mod assign_ops;
108 pub mod attrs;
109 pub mod bit_mask;
110 pub mod blacklisted_name;
111 pub mod block_in_if_condition;
112 pub mod booleans;
113 pub mod bytecount;
114 pub mod collapsible_if;
115 pub mod const_static_lifetime;
116 pub mod copies;
117 pub mod cyclomatic_complexity;
118 pub mod derive;
119 pub mod doc;
120 pub mod double_comparison;
121 pub mod double_parens;
122 pub mod drop_forget_ref;
123 pub mod else_if_without_else;
124 pub mod empty_enum;
125 pub mod entry;
126 pub mod enum_clike;
127 pub mod enum_glob_use;
128 pub mod enum_variants;
129 pub mod eq_op;
130 pub mod erasing_op;
131 pub mod escape;
132 pub mod eta_reduction;
133 pub mod eval_order_dependence;
134 pub mod excessive_precision;
135 pub mod explicit_write;
136 pub mod fallible_impl_from;
137 pub mod format;
138 pub mod formatting;
139 pub mod functions;
140 pub mod identity_conversion;
141 pub mod identity_op;
142 pub mod if_let_redundant_pattern_matching;
143 pub mod if_not_else;
144 pub mod infallible_destructuring_match;
145 pub mod infinite_iter;
146 pub mod inline_fn_without_body;
147 pub mod int_plus_one;
148 pub mod invalid_ref;
149 pub mod items_after_statements;
150 pub mod large_enum_variant;
151 pub mod len_zero;
152 pub mod let_if_seq;
153 pub mod lifetimes;
154 pub mod literal_representation;
155 pub mod loops;
156 pub mod map_clone;
157 pub mod map_unit_fn;
158 pub mod matches;
159 pub mod mem_forget;
160 pub mod methods;
161 pub mod minmax;
162 pub mod misc;
163 pub mod misc_early;
164 pub mod missing_doc;
165 pub mod multiple_crate_versions;
166 pub mod mut_mut;
167 pub mod mut_reference;
168 pub mod mutex_atomic;
169 pub mod needless_bool;
170 pub mod needless_borrow;
171 pub mod needless_borrowed_ref;
172 pub mod needless_continue;
173 pub mod needless_pass_by_value;
174 pub mod needless_update;
175 pub mod neg_multiply;
176 pub mod new_without_default;
177 pub mod no_effect;
178 pub mod non_expressive_names;
179 pub mod ok_if_let;
180 pub mod open_options;
181 pub mod overflow_check_conditional;
182 pub mod panic;
183 pub mod partialeq_ne_impl;
184 pub mod precedence;
185 pub mod ptr;
186 pub mod question_mark;
187 pub mod ranges;
188 pub mod redundant_field_names;
189 pub mod reference;
190 pub mod regex;
191 pub mod replace_consts;
192 pub mod returns;
193 pub mod serde_api;
194 pub mod shadow;
195 pub mod strings;
196 pub mod suspicious_trait_impl;
197 pub mod swap;
198 pub mod temporary_assignment;
199 pub mod transmute;
200 pub mod types;
201 pub mod unicode;
202 pub mod unsafe_removed_from_name;
203 pub mod unused_io_amount;
204 pub mod unused_label;
205 pub mod use_self;
206 pub mod vec;
207 pub mod write;
208 pub mod zero_div_zero;
209 // end lints modules, do not remove this comment, it’s used in `update_lints`
210
211 mod reexport {
212     pub use syntax::ast::{Name, NodeId};
213 }
214
215 #[cfg_attr(rustfmt, rustfmt_skip)]
216 pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
217     let conf = match utils::conf::file_from_args(reg.args()) {
218         Ok(file_name) => {
219             // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
220             // do not require the file to exist
221             let file_name = if let Some(file_name) = file_name {
222                 Some(file_name)
223             } else {
224                 match utils::conf::lookup_conf_file() {
225                     Ok(path) => path,
226                     Err(error) => {
227                         reg.sess.struct_err(&format!("error finding Clippy's configuration file: {}", error)).emit();
228                         None
229                     }
230                 }
231             };
232
233             let file_name = file_name.map(|file_name| if file_name.is_relative() {
234                 reg.sess
235                     .local_crate_source_file
236                     .as_ref()
237                     .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
238                     .unwrap_or_default()
239                     .join(file_name)
240             } else {
241                 file_name
242             });
243
244             let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
245
246             // all conf errors are non-fatal, we just use the default conf in case of error
247             for error in errors {
248                 reg.sess.struct_err(&format!("error reading Clippy's configuration file `{}`: {}", file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""), error)).emit();
249             }
250
251             conf
252         }
253         Err((err, span)) => {
254             reg.sess.struct_span_err(span, err)
255                     .span_note(span, "Clippy will use default configuration")
256                     .emit();
257             toml::from_str("").expect("we never error on empty config files")
258         }
259     };
260
261     let mut store = reg.sess.lint_store.borrow_mut();
262     store.register_removed(
263         "should_assert_eq",
264         "`assert!()` will be more flexible with RFC 2011",
265     );
266     store.register_removed(
267         "extend_from_slice",
268         "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
269     );
270     store.register_removed(
271         "range_step_by_zero",
272         "`iterator.step_by(0)` panics nowadays",
273     );
274     store.register_removed(
275         "unstable_as_slice",
276         "`Vec::as_slice` has been stabilized in 1.7",
277     );
278     store.register_removed(
279         "unstable_as_mut_slice",
280         "`Vec::as_mut_slice` has been stabilized in 1.7",
281     );
282     store.register_removed(
283         "str_to_string",
284         "using `str::to_string` is common even today and specialization will likely happen soon",
285     );
286     store.register_removed(
287         "string_to_string",
288         "using `string::to_string` is common even today and specialization will likely happen soon",
289     );
290     store.register_removed(
291         "misaligned_transmute",
292         "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
293     );
294     // end deprecated lints, do not remove this comment, it’s used in `update_lints`
295
296     reg.register_late_lint_pass(box serde_api::Serde);
297     reg.register_early_lint_pass(box utils::internal_lints::Clippy);
298     reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
299     reg.register_late_lint_pass(box utils::inspector::Pass);
300     reg.register_late_lint_pass(box utils::author::Pass);
301     reg.register_late_lint_pass(box types::TypePass);
302     reg.register_late_lint_pass(box booleans::NonminimalBool);
303     reg.register_late_lint_pass(box eq_op::EqOp);
304     reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
305     reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
306     reg.register_late_lint_pass(box enum_clike::UnportableVariant);
307     reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
308     reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
309     reg.register_late_lint_pass(box ptr::PointerPass);
310     reg.register_late_lint_pass(box needless_bool::NeedlessBool);
311     reg.register_late_lint_pass(box needless_bool::BoolComparison);
312     reg.register_late_lint_pass(box approx_const::Pass);
313     reg.register_late_lint_pass(box misc::Pass);
314     reg.register_early_lint_pass(box precedence::Precedence);
315     reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
316     reg.register_late_lint_pass(box eta_reduction::EtaPass);
317     reg.register_late_lint_pass(box identity_op::IdentityOp);
318     reg.register_late_lint_pass(box erasing_op::ErasingOp);
319     reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
320     reg.register_late_lint_pass(box mut_mut::MutMut);
321     reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
322     reg.register_late_lint_pass(box len_zero::LenZero);
323     reg.register_late_lint_pass(box attrs::AttrPass);
324     reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
325     reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
326     reg.register_late_lint_pass(box unicode::Unicode);
327     reg.register_late_lint_pass(box strings::StringAdd);
328     reg.register_early_lint_pass(box returns::ReturnPass);
329     reg.register_late_lint_pass(box methods::Pass);
330     reg.register_late_lint_pass(box shadow::Pass);
331     reg.register_late_lint_pass(box types::LetPass);
332     reg.register_late_lint_pass(box types::UnitCmp);
333     reg.register_late_lint_pass(box loops::Pass);
334     reg.register_late_lint_pass(box lifetimes::LifetimePass);
335     reg.register_late_lint_pass(box entry::HashMapLint);
336     reg.register_late_lint_pass(box ranges::Pass);
337     reg.register_late_lint_pass(box types::CastPass);
338     reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
339     reg.register_late_lint_pass(box matches::MatchPass);
340     reg.register_late_lint_pass(box minmax::MinMaxPass);
341     reg.register_late_lint_pass(box open_options::NonSensical);
342     reg.register_late_lint_pass(box zero_div_zero::Pass);
343     reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
344     reg.register_late_lint_pass(box needless_update::Pass);
345     reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow);
346     reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
347     reg.register_late_lint_pass(box no_effect::Pass);
348     reg.register_late_lint_pass(box map_clone::Pass);
349     reg.register_late_lint_pass(box temporary_assignment::Pass);
350     reg.register_late_lint_pass(box transmute::Transmute);
351     reg.register_late_lint_pass(
352         box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
353     );
354     reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
355     reg.register_early_lint_pass(box misc_early::MiscEarly);
356     reg.register_late_lint_pass(box array_indexing::ArrayIndexing);
357     reg.register_late_lint_pass(box panic::Pass);
358     reg.register_late_lint_pass(box strings::StringLitAsBytes);
359     reg.register_late_lint_pass(box derive::Derive);
360     reg.register_late_lint_pass(box types::CharLitAsU8);
361     reg.register_late_lint_pass(box write::Pass);
362     reg.register_late_lint_pass(box vec::Pass);
363     reg.register_early_lint_pass(box non_expressive_names::NonExpressiveNames {
364         single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
365     });
366     reg.register_late_lint_pass(box drop_forget_ref::Pass);
367     reg.register_late_lint_pass(box empty_enum::EmptyEnum);
368     reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
369     reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
370     reg.register_late_lint_pass(box regex::Pass::default());
371     reg.register_late_lint_pass(box copies::CopyAndPaste);
372     reg.register_late_lint_pass(box format::Pass);
373     reg.register_early_lint_pass(box formatting::Formatting);
374     reg.register_late_lint_pass(box swap::Swap);
375     reg.register_early_lint_pass(box if_not_else::IfNotElse);
376     reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
377     reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
378     reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
379     reg.register_late_lint_pass(box unused_label::UnusedLabel);
380     reg.register_late_lint_pass(box new_without_default::NewWithoutDefault);
381     reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(conf.blacklisted_names));
382     reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold));
383     reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents));
384     reg.register_late_lint_pass(box neg_multiply::NegMultiply);
385     reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
386     reg.register_late_lint_pass(box mem_forget::MemForget);
387     reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
388     reg.register_late_lint_pass(box assign_ops::AssignOps);
389     reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
390     reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
391     reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
392     reg.register_late_lint_pass(box ok_if_let::Pass);
393     reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
394     reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
395     reg.register_early_lint_pass(box reference::Pass);
396     reg.register_early_lint_pass(box double_parens::DoubleParens);
397     reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
398     reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
399     reg.register_late_lint_pass(box explicit_write::Pass);
400     reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
401     reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
402     reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
403             conf.literal_representation_threshold
404     ));
405     reg.register_late_lint_pass(box use_self::UseSelf);
406     reg.register_late_lint_pass(box bytecount::ByteCount);
407     reg.register_late_lint_pass(box infinite_iter::Pass);
408     reg.register_late_lint_pass(box inline_fn_without_body::Pass);
409     reg.register_late_lint_pass(box invalid_ref::InvalidRef);
410     reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
411     reg.register_late_lint_pass(box types::ImplicitHasher);
412     reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
413     reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
414     reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
415     reg.register_late_lint_pass(box types::UnitArg);
416     reg.register_late_lint_pass(box double_comparison::DoubleComparisonPass);
417     reg.register_late_lint_pass(box question_mark::QuestionMarkPass);
418     reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
419     reg.register_late_lint_pass(box redundant_field_names::RedundantFieldNames);
420     reg.register_early_lint_pass(box multiple_crate_versions::Pass);
421     reg.register_late_lint_pass(box map_unit_fn::Pass);
422     reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
423
424
425     reg.register_lint_group("clippy_restriction", vec![
426         arithmetic::FLOAT_ARITHMETIC,
427         arithmetic::INTEGER_ARITHMETIC,
428         array_indexing::INDEXING_SLICING,
429         assign_ops::ASSIGN_OPS,
430         else_if_without_else::ELSE_IF_WITHOUT_ELSE,
431         literal_representation::DECIMAL_LITERAL_REPRESENTATION,
432         mem_forget::MEM_FORGET,
433         methods::CLONE_ON_REF_PTR,
434         methods::OPTION_UNWRAP_USED,
435         methods::RESULT_UNWRAP_USED,
436         methods::WRONG_PUB_SELF_CONVENTION,
437         misc::FLOAT_CMP_CONST,
438         missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
439         shadow::SHADOW_REUSE,
440         shadow::SHADOW_SAME,
441         shadow::SHADOW_UNRELATED,
442         strings::STRING_ADD,
443         write::PRINT_STDOUT,
444         write::USE_DEBUG,
445     ]);
446
447     reg.register_lint_group("clippy_pedantic", vec![
448         attrs::INLINE_ALWAYS,
449         copies::MATCH_SAME_ARMS,
450         derive::EXPL_IMPL_CLONE_ON_COPY,
451         doc::DOC_MARKDOWN,
452         empty_enum::EMPTY_ENUM,
453         enum_glob_use::ENUM_GLOB_USE,
454         enum_variants::PUB_ENUM_VARIANT_NAMES,
455         enum_variants::STUTTER,
456         if_not_else::IF_NOT_ELSE,
457         infinite_iter::MAYBE_INFINITE_ITER,
458         items_after_statements::ITEMS_AFTER_STATEMENTS,
459         matches::SINGLE_MATCH_ELSE,
460         methods::FILTER_MAP,
461         methods::OPTION_MAP_UNWRAP_OR,
462         methods::OPTION_MAP_UNWRAP_OR_ELSE,
463         methods::RESULT_MAP_UNWRAP_OR_ELSE,
464         misc::USED_UNDERSCORE_BINDING,
465         misc_early::UNSEPARATED_LITERAL_SUFFIX,
466         mut_mut::MUT_MUT,
467         needless_continue::NEEDLESS_CONTINUE,
468         non_expressive_names::SIMILAR_NAMES,
469         replace_consts::REPLACE_CONSTS,
470         strings::STRING_ADD_ASSIGN,
471         types::CAST_POSSIBLE_TRUNCATION,
472         types::CAST_POSSIBLE_WRAP,
473         types::CAST_PRECISION_LOSS,
474         types::CAST_SIGN_LOSS,
475         types::INVALID_UPCAST_COMPARISONS,
476         types::LINKEDLIST,
477         unicode::NON_ASCII_LITERAL,
478         unicode::UNICODE_NOT_NFC,
479         use_self::USE_SELF,
480     ]);
481
482     reg.register_lint_group("clippy_internal", vec![
483         utils::internal_lints::CLIPPY_LINTS_INTERNAL,
484         utils::internal_lints::LINT_WITHOUT_LINT_PASS,
485     ]);
486
487     reg.register_lint_group("clippy", vec![
488         approx_const::APPROX_CONSTANT,
489         array_indexing::OUT_OF_BOUNDS_INDEXING,
490         assign_ops::ASSIGN_OP_PATTERN,
491         assign_ops::MISREFACTORED_ASSIGN_OP,
492         attrs::DEPRECATED_SEMVER,
493         attrs::USELESS_ATTRIBUTE,
494         bit_mask::BAD_BIT_MASK,
495         bit_mask::INEFFECTIVE_BIT_MASK,
496         bit_mask::VERBOSE_BIT_MASK,
497         blacklisted_name::BLACKLISTED_NAME,
498         block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
499         block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
500         booleans::LOGIC_BUG,
501         booleans::NONMINIMAL_BOOL,
502         bytecount::NAIVE_BYTECOUNT,
503         collapsible_if::COLLAPSIBLE_IF,
504         const_static_lifetime::CONST_STATIC_LIFETIME,
505         copies::IF_SAME_THEN_ELSE,
506         copies::IFS_SAME_COND,
507         cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
508         derive::DERIVE_HASH_XOR_EQ,
509         double_comparison::DOUBLE_COMPARISONS,
510         double_parens::DOUBLE_PARENS,
511         drop_forget_ref::DROP_COPY,
512         drop_forget_ref::DROP_REF,
513         drop_forget_ref::FORGET_COPY,
514         drop_forget_ref::FORGET_REF,
515         entry::MAP_ENTRY,
516         enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
517         enum_variants::ENUM_VARIANT_NAMES,
518         enum_variants::MODULE_INCEPTION,
519         eq_op::EQ_OP,
520         eq_op::OP_REF,
521         erasing_op::ERASING_OP,
522         escape::BOXED_LOCAL,
523         eta_reduction::REDUNDANT_CLOSURE,
524         eval_order_dependence::DIVERGING_SUB_EXPRESSION,
525         eval_order_dependence::EVAL_ORDER_DEPENDENCE,
526         excessive_precision::EXCESSIVE_PRECISION,
527         explicit_write::EXPLICIT_WRITE,
528         format::USELESS_FORMAT,
529         formatting::POSSIBLE_MISSING_COMMA,
530         formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
531         formatting::SUSPICIOUS_ELSE_FORMATTING,
532         functions::NOT_UNSAFE_PTR_ARG_DEREF,
533         functions::TOO_MANY_ARGUMENTS,
534         identity_conversion::IDENTITY_CONVERSION,
535         identity_op::IDENTITY_OP,
536         if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
537         infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
538         infinite_iter::INFINITE_ITER,
539         inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
540         int_plus_one::INT_PLUS_ONE,
541         invalid_ref::INVALID_REF,
542         large_enum_variant::LARGE_ENUM_VARIANT,
543         len_zero::LEN_WITHOUT_IS_EMPTY,
544         len_zero::LEN_ZERO,
545         let_if_seq::USELESS_LET_IF_SEQ,
546         lifetimes::NEEDLESS_LIFETIMES,
547         lifetimes::UNUSED_LIFETIMES,
548         literal_representation::INCONSISTENT_DIGIT_GROUPING,
549         literal_representation::LARGE_DIGIT_GROUPS,
550         literal_representation::UNREADABLE_LITERAL,
551         loops::EMPTY_LOOP,
552         loops::EXPLICIT_COUNTER_LOOP,
553         loops::EXPLICIT_INTO_ITER_LOOP,
554         loops::EXPLICIT_ITER_LOOP,
555         loops::FOR_KV_MAP,
556         loops::FOR_LOOP_OVER_OPTION,
557         loops::FOR_LOOP_OVER_RESULT,
558         loops::ITER_NEXT_LOOP,
559         loops::MANUAL_MEMCPY,
560         loops::MUT_RANGE_BOUND,
561         loops::NEEDLESS_RANGE_LOOP,
562         loops::NEVER_LOOP,
563         loops::REVERSE_RANGE_LOOP,
564         loops::UNUSED_COLLECT,
565         loops::WHILE_IMMUTABLE_CONDITION,
566         loops::WHILE_LET_LOOP,
567         loops::WHILE_LET_ON_ITERATOR,
568         map_clone::MAP_CLONE,
569         map_unit_fn::OPTION_MAP_UNIT_FN,
570         map_unit_fn::RESULT_MAP_UNIT_FN,
571         matches::MATCH_AS_REF,
572         matches::MATCH_BOOL,
573         matches::MATCH_OVERLAPPING_ARM,
574         matches::MATCH_REF_PATS,
575         matches::MATCH_WILD_ERR_ARM,
576         matches::SINGLE_MATCH,
577         methods::CHARS_LAST_CMP,
578         methods::CHARS_NEXT_CMP,
579         methods::CLONE_DOUBLE_REF,
580         methods::CLONE_ON_COPY,
581         methods::FILTER_NEXT,
582         methods::GET_UNWRAP,
583         methods::ITER_CLONED_COLLECT,
584         methods::ITER_NTH,
585         methods::ITER_SKIP_NEXT,
586         methods::NEW_RET_NO_SELF,
587         methods::OK_EXPECT,
588         methods::OPTION_MAP_OR_NONE,
589         methods::OR_FUN_CALL,
590         methods::SEARCH_IS_SOME,
591         methods::SHOULD_IMPLEMENT_TRAIT,
592         methods::SINGLE_CHAR_PATTERN,
593         methods::STRING_EXTEND_CHARS,
594         methods::TEMPORARY_CSTRING_AS_PTR,
595         methods::UNNECESSARY_FOLD,
596         methods::USELESS_ASREF,
597         methods::WRONG_SELF_CONVENTION,
598         minmax::MIN_MAX,
599         misc::CMP_NAN,
600         misc::CMP_OWNED,
601         misc::FLOAT_CMP,
602         misc::MODULO_ONE,
603         misc::REDUNDANT_PATTERN,
604         misc::SHORT_CIRCUIT_STATEMENT,
605         misc::TOPLEVEL_REF_ARG,
606         misc::ZERO_PTR,
607         misc_early::BUILTIN_TYPE_SHADOW,
608         misc_early::DOUBLE_NEG,
609         misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
610         misc_early::MIXED_CASE_HEX_LITERALS,
611         misc_early::REDUNDANT_CLOSURE_CALL,
612         misc_early::UNNEEDED_FIELD_PATTERN,
613         misc_early::ZERO_PREFIXED_LITERAL,
614         mut_reference::UNNECESSARY_MUT_PASSED,
615         mutex_atomic::MUTEX_ATOMIC,
616         needless_bool::BOOL_COMPARISON,
617         needless_bool::NEEDLESS_BOOL,
618         needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
619         needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
620         needless_update::NEEDLESS_UPDATE,
621         neg_multiply::NEG_MULTIPLY,
622         new_without_default::NEW_WITHOUT_DEFAULT,
623         new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
624         no_effect::NO_EFFECT,
625         no_effect::UNNECESSARY_OPERATION,
626         non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
627         non_expressive_names::MANY_SINGLE_CHAR_NAMES,
628         ok_if_let::IF_LET_SOME_RESULT,
629         open_options::NONSENSICAL_OPEN_OPTIONS,
630         overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
631         panic::PANIC_PARAMS,
632         partialeq_ne_impl::PARTIALEQ_NE_IMPL,
633         precedence::PRECEDENCE,
634         ptr::CMP_NULL,
635         ptr::MUT_FROM_REF,
636         ptr::PTR_ARG,
637         question_mark::QUESTION_MARK,
638         ranges::ITERATOR_STEP_BY_ZERO,
639         ranges::RANGE_MINUS_ONE,
640         ranges::RANGE_ZIP_WITH_LEN,
641         redundant_field_names::REDUNDANT_FIELD_NAMES,
642         reference::DEREF_ADDROF,
643         regex::INVALID_REGEX,
644         regex::REGEX_MACRO,
645         regex::TRIVIAL_REGEX,
646         returns::LET_AND_RETURN,
647         returns::NEEDLESS_RETURN,
648         serde_api::SERDE_API_MISUSE,
649         strings::STRING_LIT_AS_BYTES,
650         suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
651         suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
652         swap::ALMOST_SWAPPED,
653         swap::MANUAL_SWAP,
654         temporary_assignment::TEMPORARY_ASSIGNMENT,
655         transmute::CROSSPOINTER_TRANSMUTE,
656         transmute::TRANSMUTE_BYTES_TO_STR,
657         transmute::TRANSMUTE_INT_TO_BOOL,
658         transmute::TRANSMUTE_INT_TO_CHAR,
659         transmute::TRANSMUTE_INT_TO_FLOAT,
660         transmute::TRANSMUTE_PTR_TO_PTR,
661         transmute::TRANSMUTE_PTR_TO_REF,
662         transmute::USELESS_TRANSMUTE,
663         transmute::WRONG_TRANSMUTE,
664         types::ABSURD_EXTREME_COMPARISONS,
665         types::BORROWED_BOX,
666         types::BOX_VEC,
667         types::CAST_LOSSLESS,
668         types::CAST_PTR_ALIGNMENT,
669         types::CHAR_LIT_AS_U8,
670         types::IMPLICIT_HASHER,
671         types::LET_UNIT_VALUE,
672         types::OPTION_OPTION,
673         types::TYPE_COMPLEXITY,
674         types::UNIT_ARG,
675         types::UNIT_CMP,
676         types::UNNECESSARY_CAST,
677         unicode::ZERO_WIDTH_SPACE,
678         unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
679         unused_io_amount::UNUSED_IO_AMOUNT,
680         unused_label::UNUSED_LABEL,
681         vec::USELESS_VEC,
682         write::PRINT_LITERAL,
683         write::PRINT_WITH_NEWLINE,
684         write::PRINTLN_EMPTY_STRING,
685         write::WRITE_LITERAL,
686         write::WRITE_WITH_NEWLINE,
687         write::WRITELN_EMPTY_STRING,
688         zero_div_zero::ZERO_DIVIDED_BY_ZERO,
689     ]);
690
691     reg.register_lint_group("clippy_style", vec![
692         assign_ops::ASSIGN_OP_PATTERN,
693         bit_mask::VERBOSE_BIT_MASK,
694         blacklisted_name::BLACKLISTED_NAME,
695         block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
696         block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
697         collapsible_if::COLLAPSIBLE_IF,
698         const_static_lifetime::CONST_STATIC_LIFETIME,
699         enum_variants::ENUM_VARIANT_NAMES,
700         enum_variants::MODULE_INCEPTION,
701         eq_op::OP_REF,
702         eta_reduction::REDUNDANT_CLOSURE,
703         excessive_precision::EXCESSIVE_PRECISION,
704         formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
705         formatting::SUSPICIOUS_ELSE_FORMATTING,
706         if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
707         infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
708         len_zero::LEN_WITHOUT_IS_EMPTY,
709         len_zero::LEN_ZERO,
710         let_if_seq::USELESS_LET_IF_SEQ,
711         literal_representation::INCONSISTENT_DIGIT_GROUPING,
712         literal_representation::LARGE_DIGIT_GROUPS,
713         literal_representation::UNREADABLE_LITERAL,
714         loops::EMPTY_LOOP,
715         loops::EXPLICIT_INTO_ITER_LOOP,
716         loops::EXPLICIT_ITER_LOOP,
717         loops::FOR_KV_MAP,
718         loops::NEEDLESS_RANGE_LOOP,
719         loops::WHILE_LET_ON_ITERATOR,
720         map_clone::MAP_CLONE,
721         matches::MATCH_BOOL,
722         matches::MATCH_OVERLAPPING_ARM,
723         matches::MATCH_REF_PATS,
724         matches::MATCH_WILD_ERR_ARM,
725         matches::SINGLE_MATCH,
726         methods::CHARS_LAST_CMP,
727         methods::GET_UNWRAP,
728         methods::ITER_CLONED_COLLECT,
729         methods::ITER_SKIP_NEXT,
730         methods::NEW_RET_NO_SELF,
731         methods::OK_EXPECT,
732         methods::OPTION_MAP_OR_NONE,
733         methods::SHOULD_IMPLEMENT_TRAIT,
734         methods::STRING_EXTEND_CHARS,
735         methods::UNNECESSARY_FOLD,
736         methods::WRONG_SELF_CONVENTION,
737         misc::REDUNDANT_PATTERN,
738         misc::TOPLEVEL_REF_ARG,
739         misc::ZERO_PTR,
740         misc_early::BUILTIN_TYPE_SHADOW,
741         misc_early::DOUBLE_NEG,
742         misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
743         misc_early::MIXED_CASE_HEX_LITERALS,
744         misc_early::UNNEEDED_FIELD_PATTERN,
745         mut_reference::UNNECESSARY_MUT_PASSED,
746         needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
747         neg_multiply::NEG_MULTIPLY,
748         new_without_default::NEW_WITHOUT_DEFAULT,
749         new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
750         non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
751         non_expressive_names::MANY_SINGLE_CHAR_NAMES,
752         ok_if_let::IF_LET_SOME_RESULT,
753         panic::PANIC_PARAMS,
754         ptr::CMP_NULL,
755         ptr::PTR_ARG,
756         question_mark::QUESTION_MARK,
757         ranges::RANGE_MINUS_ONE,
758         redundant_field_names::REDUNDANT_FIELD_NAMES,
759         regex::REGEX_MACRO,
760         regex::TRIVIAL_REGEX,
761         returns::LET_AND_RETURN,
762         returns::NEEDLESS_RETURN,
763         strings::STRING_LIT_AS_BYTES,
764         types::IMPLICIT_HASHER,
765         types::LET_UNIT_VALUE,
766         unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
767         write::PRINT_LITERAL,
768         write::PRINT_WITH_NEWLINE,
769         write::PRINTLN_EMPTY_STRING,
770         write::WRITE_LITERAL,
771         write::WRITE_WITH_NEWLINE,
772         write::WRITELN_EMPTY_STRING,
773     ]);
774
775     reg.register_lint_group("clippy_complexity", vec![
776         assign_ops::MISREFACTORED_ASSIGN_OP,
777         booleans::NONMINIMAL_BOOL,
778         cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
779         double_comparison::DOUBLE_COMPARISONS,
780         double_parens::DOUBLE_PARENS,
781         eval_order_dependence::DIVERGING_SUB_EXPRESSION,
782         eval_order_dependence::EVAL_ORDER_DEPENDENCE,
783         explicit_write::EXPLICIT_WRITE,
784         format::USELESS_FORMAT,
785         functions::TOO_MANY_ARGUMENTS,
786         identity_conversion::IDENTITY_CONVERSION,
787         identity_op::IDENTITY_OP,
788         int_plus_one::INT_PLUS_ONE,
789         lifetimes::NEEDLESS_LIFETIMES,
790         lifetimes::UNUSED_LIFETIMES,
791         loops::EXPLICIT_COUNTER_LOOP,
792         loops::MUT_RANGE_BOUND,
793         loops::WHILE_LET_LOOP,
794         map_unit_fn::OPTION_MAP_UNIT_FN,
795         map_unit_fn::RESULT_MAP_UNIT_FN,
796         matches::MATCH_AS_REF,
797         methods::CHARS_NEXT_CMP,
798         methods::CLONE_ON_COPY,
799         methods::FILTER_NEXT,
800         methods::SEARCH_IS_SOME,
801         methods::USELESS_ASREF,
802         misc::SHORT_CIRCUIT_STATEMENT,
803         misc_early::REDUNDANT_CLOSURE_CALL,
804         misc_early::ZERO_PREFIXED_LITERAL,
805         needless_bool::BOOL_COMPARISON,
806         needless_bool::NEEDLESS_BOOL,
807         needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
808         needless_update::NEEDLESS_UPDATE,
809         no_effect::NO_EFFECT,
810         no_effect::UNNECESSARY_OPERATION,
811         overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
812         partialeq_ne_impl::PARTIALEQ_NE_IMPL,
813         precedence::PRECEDENCE,
814         ranges::RANGE_ZIP_WITH_LEN,
815         reference::DEREF_ADDROF,
816         swap::MANUAL_SWAP,
817         temporary_assignment::TEMPORARY_ASSIGNMENT,
818         transmute::CROSSPOINTER_TRANSMUTE,
819         transmute::TRANSMUTE_BYTES_TO_STR,
820         transmute::TRANSMUTE_INT_TO_BOOL,
821         transmute::TRANSMUTE_INT_TO_CHAR,
822         transmute::TRANSMUTE_INT_TO_FLOAT,
823         transmute::TRANSMUTE_PTR_TO_PTR,
824         transmute::TRANSMUTE_PTR_TO_REF,
825         transmute::USELESS_TRANSMUTE,
826         types::BORROWED_BOX,
827         types::CAST_LOSSLESS,
828         types::CHAR_LIT_AS_U8,
829         types::OPTION_OPTION,
830         types::TYPE_COMPLEXITY,
831         types::UNIT_ARG,
832         types::UNNECESSARY_CAST,
833         unused_label::UNUSED_LABEL,
834         zero_div_zero::ZERO_DIVIDED_BY_ZERO,
835     ]);
836
837     reg.register_lint_group("clippy_correctness", vec![
838         approx_const::APPROX_CONSTANT,
839         array_indexing::OUT_OF_BOUNDS_INDEXING,
840         attrs::DEPRECATED_SEMVER,
841         attrs::USELESS_ATTRIBUTE,
842         bit_mask::BAD_BIT_MASK,
843         bit_mask::INEFFECTIVE_BIT_MASK,
844         booleans::LOGIC_BUG,
845         copies::IF_SAME_THEN_ELSE,
846         copies::IFS_SAME_COND,
847         derive::DERIVE_HASH_XOR_EQ,
848         drop_forget_ref::DROP_COPY,
849         drop_forget_ref::DROP_REF,
850         drop_forget_ref::FORGET_COPY,
851         drop_forget_ref::FORGET_REF,
852         enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
853         eq_op::EQ_OP,
854         erasing_op::ERASING_OP,
855         formatting::POSSIBLE_MISSING_COMMA,
856         functions::NOT_UNSAFE_PTR_ARG_DEREF,
857         infinite_iter::INFINITE_ITER,
858         inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
859         invalid_ref::INVALID_REF,
860         loops::FOR_LOOP_OVER_OPTION,
861         loops::FOR_LOOP_OVER_RESULT,
862         loops::ITER_NEXT_LOOP,
863         loops::NEVER_LOOP,
864         loops::REVERSE_RANGE_LOOP,
865         loops::WHILE_IMMUTABLE_CONDITION,
866         methods::CLONE_DOUBLE_REF,
867         methods::TEMPORARY_CSTRING_AS_PTR,
868         minmax::MIN_MAX,
869         misc::CMP_NAN,
870         misc::FLOAT_CMP,
871         misc::MODULO_ONE,
872         open_options::NONSENSICAL_OPEN_OPTIONS,
873         ptr::MUT_FROM_REF,
874         ranges::ITERATOR_STEP_BY_ZERO,
875         regex::INVALID_REGEX,
876         serde_api::SERDE_API_MISUSE,
877         suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
878         suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
879         swap::ALMOST_SWAPPED,
880         transmute::WRONG_TRANSMUTE,
881         types::ABSURD_EXTREME_COMPARISONS,
882         types::CAST_PTR_ALIGNMENT,
883         types::UNIT_CMP,
884         unicode::ZERO_WIDTH_SPACE,
885         unused_io_amount::UNUSED_IO_AMOUNT,
886     ]);
887
888     reg.register_lint_group("clippy_perf", vec![
889         bytecount::NAIVE_BYTECOUNT,
890         entry::MAP_ENTRY,
891         escape::BOXED_LOCAL,
892         large_enum_variant::LARGE_ENUM_VARIANT,
893         loops::MANUAL_MEMCPY,
894         loops::UNUSED_COLLECT,
895         methods::ITER_NTH,
896         methods::OR_FUN_CALL,
897         methods::SINGLE_CHAR_PATTERN,
898         misc::CMP_OWNED,
899         mutex_atomic::MUTEX_ATOMIC,
900         types::BOX_VEC,
901         vec::USELESS_VEC,
902     ]);
903
904     reg.register_lint_group("clippy_cargo", vec![
905         multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
906     ]);
907
908     reg.register_lint_group("clippy_nursery", vec![
909         attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
910         fallible_impl_from::FALLIBLE_IMPL_FROM,
911         mutex_atomic::MUTEX_INTEGER,
912         needless_borrow::NEEDLESS_BORROW,
913         ranges::RANGE_PLUS_ONE,
914     ]);
915 }
916
917 // only exists to let the dogfood integration test works.
918 // Don't run clippy as an executable directly
919 #[allow(dead_code, print_stdout)]
920 fn main() {
921     panic!("Please use the cargo-clippy executable");
922 }