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