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