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