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