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