]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/lib.rs
rustup https://github.com/rust-lang/rust/pull/61758/files
[rust.git] / clippy_lints / src / lib.rs
1 // error-pattern:cargo-clippy
2
3 #![feature(box_syntax)]
4 #![feature(never_type)]
5 #![feature(rustc_private)]
6 #![feature(slice_patterns)]
7 #![feature(stmt_expr_attributes)]
8 #![allow(clippy::missing_docs_in_private_items)]
9 #![recursion_limit = "512"]
10 #![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)]
11 #![deny(internal)]
12 #![feature(crate_visibility_modifier)]
13 #![feature(concat_idents)]
14
15 // FIXME: switch to something more ergonomic here, once available.
16 // (Currently there is no way to opt into sysroot crates without `extern crate`.)
17 #[allow(unused_extern_crates)]
18 extern crate fmt_macros;
19 #[allow(unused_extern_crates)]
20 extern crate rustc;
21 #[allow(unused_extern_crates)]
22 extern crate rustc_data_structures;
23 #[allow(unused_extern_crates)]
24 extern crate rustc_errors;
25 #[allow(unused_extern_crates)]
26 extern crate rustc_mir;
27 #[allow(unused_extern_crates)]
28 extern crate rustc_plugin;
29 #[allow(unused_extern_crates)]
30 extern crate rustc_target;
31 #[allow(unused_extern_crates)]
32 extern crate rustc_typeck;
33 #[allow(unused_extern_crates)]
34 extern crate syntax;
35 #[allow(unused_extern_crates)]
36 extern crate syntax_pos;
37
38 use toml;
39
40 /// Macro used to declare a Clippy lint.
41 ///
42 /// Every lint declaration consists of 4 parts:
43 ///
44 /// 1. The documentation, which is used for the website
45 /// 2. The `LINT_NAME`. See [lint naming][lint_naming] on lint naming conventions.
46 /// 3. The `lint_level`, which is a mapping from *one* of our lint groups to `Allow`, `Warn` or
47 ///    `Deny`. The lint level here has nothing to do with what lint groups the lint is a part of.
48 /// 4. The `description` that contains a short explanation on what's wrong with code where the
49 ///    lint is triggered.
50 ///
51 /// Currently the categories `style`, `correctness`, `complexity` and `perf` are enabled by default.
52 /// As said in the README.md of this repository, if the lint level mapping changes, please update
53 /// README.md.
54 ///
55 /// # Example
56 ///
57 /// ```
58 /// # #![feature(rustc_private)]
59 /// # #[allow(unused_extern_crates)]
60 /// # extern crate rustc;
61 /// # #[macro_use]
62 /// # use clippy_lints::declare_clippy_lint;
63 /// use rustc::declare_tool_lint;
64 ///
65 /// declare_clippy_lint! {
66 ///     /// **What it does:** Checks for ... (describe what the lint matches).
67 ///     ///
68 ///     /// **Why is this bad?** Supply the reason for linting the code.
69 ///     ///
70 ///     /// **Known problems:** None. (Or describe where it could go wrong.)
71 ///     ///
72 ///     /// **Example:**
73 ///     ///
74 ///     /// ```rust
75 ///     /// // Bad
76 ///     /// Insert a short example of code that triggers the lint
77 ///     ///
78 ///     /// // Good
79 ///     /// Insert a short example of improved code that doesn't trigger the lint
80 ///     /// ```
81 ///     pub LINT_NAME,
82 ///     pedantic,
83 ///     "description"
84 /// }
85 /// ```
86 /// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
87 #[macro_export]
88 macro_rules! declare_clippy_lint {
89     { $(#[$attr:meta])* pub $name:tt, style, $description:tt } => {
90         declare_tool_lint! {
91             $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
92         }
93     };
94     { $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => {
95         declare_tool_lint! {
96             $(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
97         }
98     };
99     { $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
100         declare_tool_lint! {
101             pub clippy::$name, Warn, $description, report_in_external_macro: true
102         }
103     };
104     { $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => {
105         declare_tool_lint! {
106             pub clippy::$name, Warn, $description, report_in_external_macro: true
107         }
108     };
109     { $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => {
110         declare_tool_lint! {
111             pub clippy::$name, Allow, $description, report_in_external_macro: true
112         }
113     };
114     { $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
115         declare_tool_lint! {
116             pub clippy::$name, Allow, $description, report_in_external_macro: true
117         }
118     };
119     { $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
120         declare_tool_lint! {
121             pub clippy::$name, Allow, $description, report_in_external_macro: true
122         }
123     };
124     { $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => {
125         declare_tool_lint! {
126             pub clippy::$name, Allow, $description, report_in_external_macro: true
127         }
128     };
129     { $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => {
130         declare_tool_lint! {
131             pub clippy::$name, Allow, $description, report_in_external_macro: true
132         }
133     };
134     { $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => {
135         declare_tool_lint! {
136             pub clippy::$name, Warn, $description, report_in_external_macro: true
137         }
138     };
139 }
140
141 mod consts;
142 #[macro_use]
143 mod utils;
144
145 // begin lints modules, do not remove this comment, it’s used in `update_lints`
146 pub mod approx_const;
147 pub mod arithmetic;
148 pub mod assertions_on_constants;
149 pub mod assign_ops;
150 pub mod attrs;
151 pub mod bit_mask;
152 pub mod blacklisted_name;
153 pub mod block_in_if_condition;
154 pub mod booleans;
155 pub mod bytecount;
156 pub mod cargo_common_metadata;
157 pub mod checked_conversions;
158 pub mod cognitive_complexity;
159 pub mod collapsible_if;
160 pub mod const_static_lifetime;
161 pub mod copies;
162 pub mod copy_iterator;
163 pub mod dbg_macro;
164 pub mod default_trait_access;
165 pub mod derive;
166 pub mod doc;
167 pub mod double_comparison;
168 pub mod double_parens;
169 pub mod drop_bounds;
170 pub mod drop_forget_ref;
171 pub mod duration_subsec;
172 pub mod else_if_without_else;
173 pub mod empty_enum;
174 pub mod entry;
175 pub mod enum_clike;
176 pub mod enum_glob_use;
177 pub mod enum_variants;
178 pub mod eq_op;
179 pub mod erasing_op;
180 pub mod escape;
181 pub mod eta_reduction;
182 pub mod eval_order_dependence;
183 pub mod excessive_precision;
184 pub mod explicit_write;
185 pub mod fallible_impl_from;
186 pub mod format;
187 pub mod formatting;
188 pub mod functions;
189 pub mod get_last_with_len;
190 pub mod identity_conversion;
191 pub mod identity_op;
192 pub mod if_not_else;
193 pub mod implicit_return;
194 pub mod indexing_slicing;
195 pub mod infallible_destructuring_match;
196 pub mod infinite_iter;
197 pub mod inherent_impl;
198 pub mod inline_fn_without_body;
199 pub mod int_plus_one;
200 pub mod invalid_ref;
201 pub mod items_after_statements;
202 pub mod large_enum_variant;
203 pub mod len_zero;
204 pub mod let_if_seq;
205 pub mod lifetimes;
206 pub mod literal_representation;
207 pub mod loops;
208 pub mod map_clone;
209 pub mod map_unit_fn;
210 pub mod matches;
211 pub mod mem_discriminant;
212 pub mod mem_forget;
213 pub mod mem_replace;
214 pub mod methods;
215 pub mod minmax;
216 pub mod misc;
217 pub mod misc_early;
218 pub mod missing_const_for_fn;
219 pub mod missing_doc;
220 pub mod missing_inline;
221 pub mod multiple_crate_versions;
222 pub mod mut_mut;
223 pub mod mut_reference;
224 pub mod mutex_atomic;
225 pub mod needless_bool;
226 pub mod needless_borrow;
227 pub mod needless_borrowed_ref;
228 pub mod needless_continue;
229 pub mod needless_pass_by_value;
230 pub mod needless_update;
231 pub mod neg_cmp_op_on_partial_ord;
232 pub mod neg_multiply;
233 pub mod new_without_default;
234 pub mod no_effect;
235 pub mod non_copy_const;
236 pub mod non_expressive_names;
237 pub mod ok_if_let;
238 pub mod open_options;
239 pub mod overflow_check_conditional;
240 pub mod panic_unimplemented;
241 pub mod partialeq_ne_impl;
242 pub mod path_buf_push_overwrite;
243 pub mod precedence;
244 pub mod ptr;
245 pub mod ptr_offset_with_cast;
246 pub mod question_mark;
247 pub mod ranges;
248 pub mod redundant_clone;
249 pub mod redundant_field_names;
250 pub mod redundant_pattern_matching;
251 pub mod reference;
252 pub mod regex;
253 pub mod replace_consts;
254 pub mod returns;
255 pub mod serde_api;
256 pub mod shadow;
257 pub mod slow_vector_initialization;
258 pub mod strings;
259 pub mod suspicious_trait_impl;
260 pub mod swap;
261 pub mod temporary_assignment;
262 pub mod transmute;
263 pub mod transmuting_null;
264 pub mod trivially_copy_pass_by_ref;
265 pub mod types;
266 pub mod unicode;
267 pub mod unsafe_removed_from_name;
268 pub mod unused_io_amount;
269 pub mod unused_label;
270 pub mod unwrap;
271 pub mod use_self;
272 pub mod vec;
273 pub mod wildcard_dependencies;
274 pub mod write;
275 pub mod zero_div_zero;
276 // end lints modules, do not remove this comment, it’s used in `update_lints`
277
278 pub use crate::utils::conf::Conf;
279
280 mod reexport {
281     crate use syntax::ast::Name;
282 }
283
284 /// Register all pre expansion lints
285 ///
286 /// Pre-expansion lints run before any macro expansion has happened.
287 ///
288 /// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
289 /// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
290 ///
291 /// Used in `./src/driver.rs`.
292 pub fn register_pre_expansion_lints(
293     session: &rustc::session::Session,
294     store: &mut rustc::lint::LintStore,
295     conf: &Conf,
296 ) {
297     store.register_pre_expansion_pass(Some(session), true, false, box write::Write);
298     store.register_pre_expansion_pass(
299         Some(session),
300         true,
301         false,
302         box redundant_field_names::RedundantFieldNames,
303     );
304     store.register_pre_expansion_pass(
305         Some(session),
306         true,
307         false,
308         box non_expressive_names::NonExpressiveNames {
309             single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
310         },
311     );
312     store.register_pre_expansion_pass(Some(session), true, false, box attrs::DeprecatedCfgAttribute);
313     store.register_pre_expansion_pass(Some(session), true, false, box dbg_macro::DbgMacro);
314 }
315
316 #[doc(hidden)]
317 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
318     match utils::conf::file_from_args(reg.args()) {
319         Ok(file_name) => {
320             // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
321             // do not require the file to exist
322             let file_name = if let Some(file_name) = file_name {
323                 Some(file_name)
324             } else {
325                 match utils::conf::lookup_conf_file() {
326                     Ok(path) => path,
327                     Err(error) => {
328                         reg.sess
329                             .struct_err(&format!("error finding Clippy's configuration file: {}", error))
330                             .emit();
331                         None
332                     },
333                 }
334             };
335
336             let file_name = file_name.map(|file_name| {
337                 if file_name.is_relative() {
338                     reg.sess
339                         .local_crate_source_file
340                         .as_ref()
341                         .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
342                         .unwrap_or_default()
343                         .join(file_name)
344                 } else {
345                     file_name
346                 }
347             });
348
349             let (conf, errors) = utils::conf::read(file_name.as_ref().map(std::convert::AsRef::as_ref));
350
351             // all conf errors are non-fatal, we just use the default conf in case of error
352             for error in errors {
353                 reg.sess
354                     .struct_err(&format!(
355                         "error reading Clippy's configuration file `{}`: {}",
356                         file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""),
357                         error
358                     ))
359                     .emit();
360             }
361
362             conf
363         },
364         Err((err, span)) => {
365             reg.sess
366                 .struct_span_err(span, err)
367                 .span_note(span, "Clippy will use default configuration")
368                 .emit();
369             toml::from_str("").expect("we never error on empty config files")
370         },
371     }
372 }
373
374 /// Register all lints and lint groups with the rustc plugin registry
375 ///
376 /// Used in `./src/driver.rs`.
377 #[allow(clippy::too_many_lines)]
378 #[rustfmt::skip]
379 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
380     let mut store = reg.sess.lint_store.borrow_mut();
381     // begin deprecated lints, do not remove this comment, it’s used in `update_lints`
382     store.register_removed(
383         "should_assert_eq",
384         "`assert!()` will be more flexible with RFC 2011",
385     );
386     store.register_removed(
387         "extend_from_slice",
388         "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
389     );
390     store.register_removed(
391         "range_step_by_zero",
392         "`iterator.step_by(0)` panics nowadays",
393     );
394     store.register_removed(
395         "unstable_as_slice",
396         "`Vec::as_slice` has been stabilized in 1.7",
397     );
398     store.register_removed(
399         "unstable_as_mut_slice",
400         "`Vec::as_mut_slice` has been stabilized in 1.7",
401     );
402     store.register_removed(
403         "str_to_string",
404         "using `str::to_string` is common even today and specialization will likely happen soon",
405     );
406     store.register_removed(
407         "string_to_string",
408         "using `string::to_string` is common even today and specialization will likely happen soon",
409     );
410     store.register_removed(
411         "misaligned_transmute",
412         "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
413     );
414     store.register_removed(
415         "assign_ops",
416         "using compound assignment operators (e.g., `+=`) is harmless",
417     );
418     store.register_removed(
419         "if_let_redundant_pattern_matching",
420         "this lint has been changed to redundant_pattern_matching",
421     );
422     store.register_removed(
423         "unsafe_vector_initialization",
424         "the replacement suggested by this lint had substantially different behavior",
425     );
426     // end deprecated lints, do not remove this comment, it’s used in `update_lints`
427
428     reg.register_late_lint_pass(box serde_api::SerdeAPI);
429     reg.register_early_lint_pass(box utils::internal_lints::ClippyLintsInternal);
430     reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
431     reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
432     reg.register_late_lint_pass(box utils::internal_lints::OuterExpnInfoPass);
433     reg.register_late_lint_pass(box utils::inspector::DeepCodeInspector);
434     reg.register_late_lint_pass(box utils::author::Author);
435     reg.register_late_lint_pass(box types::Types);
436     reg.register_late_lint_pass(box booleans::NonminimalBool);
437     reg.register_late_lint_pass(box eq_op::EqOp);
438     reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
439     reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
440     reg.register_late_lint_pass(box enum_clike::UnportableVariant);
441     reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
442     reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
443     reg.register_late_lint_pass(box ptr::Ptr);
444     reg.register_late_lint_pass(box needless_bool::NeedlessBool);
445     reg.register_late_lint_pass(box needless_bool::BoolComparison);
446     reg.register_late_lint_pass(box approx_const::ApproxConstant);
447     reg.register_late_lint_pass(box misc::MiscLints);
448     reg.register_early_lint_pass(box precedence::Precedence);
449     reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
450     reg.register_late_lint_pass(box eta_reduction::EtaReduction);
451     reg.register_late_lint_pass(box identity_op::IdentityOp);
452     reg.register_late_lint_pass(box erasing_op::ErasingOp);
453     reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
454     reg.register_late_lint_pass(box mut_mut::MutMut);
455     reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
456     reg.register_late_lint_pass(box len_zero::LenZero);
457     reg.register_late_lint_pass(box attrs::Attributes);
458     reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
459     reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
460     reg.register_late_lint_pass(box unicode::Unicode);
461     reg.register_late_lint_pass(box strings::StringAdd);
462     reg.register_early_lint_pass(box returns::Return);
463     reg.register_late_lint_pass(box implicit_return::ImplicitReturn);
464     reg.register_late_lint_pass(box methods::Methods);
465     reg.register_late_lint_pass(box map_clone::MapClone);
466     reg.register_late_lint_pass(box shadow::Shadow);
467     reg.register_late_lint_pass(box types::LetUnitValue);
468     reg.register_late_lint_pass(box types::UnitCmp);
469     reg.register_late_lint_pass(box loops::Loops);
470     reg.register_late_lint_pass(box lifetimes::Lifetimes);
471     reg.register_late_lint_pass(box entry::HashMapPass);
472     reg.register_late_lint_pass(box ranges::Ranges);
473     reg.register_late_lint_pass(box types::Casts);
474     reg.register_late_lint_pass(box types::TypeComplexity::new(conf.type_complexity_threshold));
475     reg.register_late_lint_pass(box matches::Matches);
476     reg.register_late_lint_pass(box minmax::MinMaxPass);
477     reg.register_late_lint_pass(box open_options::OpenOptions);
478     reg.register_late_lint_pass(box zero_div_zero::ZeroDiv);
479     reg.register_late_lint_pass(box mutex_atomic::Mutex);
480     reg.register_late_lint_pass(box needless_update::NeedlessUpdate);
481     reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow::default());
482     reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
483     reg.register_late_lint_pass(box no_effect::NoEffect);
484     reg.register_late_lint_pass(box temporary_assignment::TemporaryAssignment);
485     reg.register_late_lint_pass(box transmute::Transmute);
486     reg.register_late_lint_pass(
487         box cognitive_complexity::CognitiveComplexity::new(conf.cognitive_complexity_threshold)
488     );
489     reg.register_late_lint_pass(box escape::BoxedLocal{too_large_for_stack: conf.too_large_for_stack});
490     reg.register_early_lint_pass(box misc_early::MiscEarlyLints);
491     reg.register_late_lint_pass(box panic_unimplemented::PanicUnimplemented);
492     reg.register_late_lint_pass(box strings::StringLitAsBytes);
493     reg.register_late_lint_pass(box derive::Derive);
494     reg.register_late_lint_pass(box types::CharLitAsU8);
495     reg.register_late_lint_pass(box vec::UselessVec);
496     reg.register_late_lint_pass(box drop_bounds::DropBounds);
497     reg.register_late_lint_pass(box get_last_with_len::GetLastWithLen);
498     reg.register_late_lint_pass(box drop_forget_ref::DropForgetRef);
499     reg.register_late_lint_pass(box empty_enum::EmptyEnum);
500     reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
501     reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
502     reg.register_late_lint_pass(box regex::Regex::default());
503     reg.register_late_lint_pass(box copies::CopyAndPaste);
504     reg.register_late_lint_pass(box copy_iterator::CopyIterator);
505     reg.register_late_lint_pass(box format::UselessFormat);
506     reg.register_early_lint_pass(box formatting::Formatting);
507     reg.register_late_lint_pass(box swap::Swap);
508     reg.register_early_lint_pass(box if_not_else::IfNotElse);
509     reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
510     reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
511     reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
512     reg.register_late_lint_pass(box unused_label::UnusedLabel);
513     reg.register_late_lint_pass(box new_without_default::NewWithoutDefault::default());
514     reg.register_late_lint_pass(box blacklisted_name::BlacklistedName::new(
515             conf.blacklisted_names.iter().cloned().collect()
516     ));
517     reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold, conf.too_many_lines_threshold));
518     reg.register_early_lint_pass(box doc::DocMarkdown::new(conf.doc_valid_idents.iter().cloned().collect()));
519     reg.register_late_lint_pass(box neg_multiply::NegMultiply);
520     reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
521     reg.register_late_lint_pass(box mem_discriminant::MemDiscriminant);
522     reg.register_late_lint_pass(box mem_forget::MemForget);
523     reg.register_late_lint_pass(box mem_replace::MemReplace);
524     reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
525     reg.register_late_lint_pass(box assign_ops::AssignOps);
526     reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
527     reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
528     reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
529     reg.register_late_lint_pass(box missing_inline::MissingInline);
530     reg.register_late_lint_pass(box ok_if_let::OkIfLet);
531     reg.register_late_lint_pass(box redundant_pattern_matching::RedundantPatternMatching);
532     reg.register_late_lint_pass(box partialeq_ne_impl::PartialEqNeImpl);
533     reg.register_early_lint_pass(box reference::DerefAddrOf);
534     reg.register_early_lint_pass(box reference::RefInDeref);
535     reg.register_early_lint_pass(box double_parens::DoubleParens);
536     reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
537     reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
538     reg.register_late_lint_pass(box explicit_write::ExplicitWrite);
539     reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
540     reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
541             conf.trivial_copy_size_limit,
542             &reg.sess.target,
543     ));
544     reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
545     reg.register_early_lint_pass(box literal_representation::DecimalLiteralRepresentation::new(
546             conf.literal_representation_threshold
547     ));
548     reg.register_late_lint_pass(box use_self::UseSelf);
549     reg.register_late_lint_pass(box bytecount::ByteCount);
550     reg.register_late_lint_pass(box infinite_iter::InfiniteIter);
551     reg.register_late_lint_pass(box inline_fn_without_body::InlineFnWithoutBody);
552     reg.register_late_lint_pass(box invalid_ref::InvalidRef);
553     reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
554     reg.register_late_lint_pass(box types::ImplicitHasher);
555     reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
556     reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
557     reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
558     reg.register_late_lint_pass(box types::UnitArg);
559     reg.register_late_lint_pass(box double_comparison::DoubleComparisons);
560     reg.register_late_lint_pass(box question_mark::QuestionMark);
561     reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
562     reg.register_early_lint_pass(box cargo_common_metadata::CargoCommonMetadata);
563     reg.register_early_lint_pass(box multiple_crate_versions::MultipleCrateVersions);
564     reg.register_early_lint_pass(box wildcard_dependencies::WildcardDependencies);
565     reg.register_late_lint_pass(box map_unit_fn::MapUnit);
566     reg.register_late_lint_pass(box infallible_destructuring_match::InfallibleDestructingMatch);
567     reg.register_late_lint_pass(box inherent_impl::MultipleInherentImpl::default());
568     reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
569     reg.register_late_lint_pass(box unwrap::Unwrap);
570     reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
571     reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
572     reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
573     reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
574     reg.register_late_lint_pass(box ptr_offset_with_cast::PtrOffsetWithCast);
575     reg.register_late_lint_pass(box redundant_clone::RedundantClone);
576     reg.register_late_lint_pass(box slow_vector_initialization::SlowVectorInit);
577     reg.register_late_lint_pass(box types::RefToMut);
578     reg.register_late_lint_pass(box assertions_on_constants::AssertionsOnConstants);
579     reg.register_late_lint_pass(box missing_const_for_fn::MissingConstForFn);
580     reg.register_late_lint_pass(box transmuting_null::TransmutingNull);
581     reg.register_late_lint_pass(box path_buf_push_overwrite::PathBufPushOverwrite);
582     reg.register_late_lint_pass(box checked_conversions::CheckedConversions);
583
584     reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
585         arithmetic::FLOAT_ARITHMETIC,
586         arithmetic::INTEGER_ARITHMETIC,
587         dbg_macro::DBG_MACRO,
588         else_if_without_else::ELSE_IF_WITHOUT_ELSE,
589         implicit_return::IMPLICIT_RETURN,
590         indexing_slicing::INDEXING_SLICING,
591         inherent_impl::MULTIPLE_INHERENT_IMPL,
592         literal_representation::DECIMAL_LITERAL_REPRESENTATION,
593         matches::WILDCARD_ENUM_MATCH_ARM,
594         mem_forget::MEM_FORGET,
595         methods::CLONE_ON_REF_PTR,
596         methods::GET_UNWRAP,
597         methods::OPTION_UNWRAP_USED,
598         methods::RESULT_UNWRAP_USED,
599         methods::WRONG_PUB_SELF_CONVENTION,
600         misc::FLOAT_CMP_CONST,
601         missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
602         missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
603         panic_unimplemented::UNIMPLEMENTED,
604         shadow::SHADOW_REUSE,
605         shadow::SHADOW_SAME,
606         strings::STRING_ADD,
607         write::PRINT_STDOUT,
608         write::USE_DEBUG,
609     ]);
610
611     reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
612         attrs::INLINE_ALWAYS,
613         checked_conversions::CHECKED_CONVERSIONS,
614         copies::MATCH_SAME_ARMS,
615         copy_iterator::COPY_ITERATOR,
616         default_trait_access::DEFAULT_TRAIT_ACCESS,
617         derive::EXPL_IMPL_CLONE_ON_COPY,
618         doc::DOC_MARKDOWN,
619         empty_enum::EMPTY_ENUM,
620         enum_glob_use::ENUM_GLOB_USE,
621         enum_variants::MODULE_NAME_REPETITIONS,
622         enum_variants::PUB_ENUM_VARIANT_NAMES,
623         eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
624         functions::TOO_MANY_LINES,
625         if_not_else::IF_NOT_ELSE,
626         infinite_iter::MAYBE_INFINITE_ITER,
627         items_after_statements::ITEMS_AFTER_STATEMENTS,
628         literal_representation::LARGE_DIGIT_GROUPS,
629         loops::EXPLICIT_INTO_ITER_LOOP,
630         loops::EXPLICIT_ITER_LOOP,
631         matches::SINGLE_MATCH_ELSE,
632         methods::FILTER_MAP,
633         methods::FILTER_MAP_NEXT,
634         methods::FIND_MAP,
635         methods::MAP_FLATTEN,
636         methods::OPTION_MAP_UNWRAP_OR,
637         methods::OPTION_MAP_UNWRAP_OR_ELSE,
638         methods::RESULT_MAP_UNWRAP_OR_ELSE,
639         misc::USED_UNDERSCORE_BINDING,
640         misc_early::UNSEPARATED_LITERAL_SUFFIX,
641         mut_mut::MUT_MUT,
642         needless_continue::NEEDLESS_CONTINUE,
643         needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
644         non_expressive_names::SIMILAR_NAMES,
645         replace_consts::REPLACE_CONSTS,
646         shadow::SHADOW_UNRELATED,
647         strings::STRING_ADD_ASSIGN,
648         types::CAST_POSSIBLE_TRUNCATION,
649         types::CAST_POSSIBLE_WRAP,
650         types::CAST_PRECISION_LOSS,
651         types::CAST_SIGN_LOSS,
652         types::INVALID_UPCAST_COMPARISONS,
653         types::LINKEDLIST,
654         unicode::NON_ASCII_LITERAL,
655         unicode::UNICODE_NOT_NFC,
656         use_self::USE_SELF,
657     ]);
658
659     reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
660         utils::internal_lints::CLIPPY_LINTS_INTERNAL,
661         utils::internal_lints::COMPILER_LINT_FUNCTIONS,
662         utils::internal_lints::LINT_WITHOUT_LINT_PASS,
663         utils::internal_lints::OUTER_EXPN_INFO,
664     ]);
665
666     reg.register_lint_group("clippy::all", Some("clippy"), vec![
667         approx_const::APPROX_CONSTANT,
668         assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
669         assign_ops::ASSIGN_OP_PATTERN,
670         assign_ops::MISREFACTORED_ASSIGN_OP,
671         attrs::DEPRECATED_CFG_ATTR,
672         attrs::DEPRECATED_SEMVER,
673         attrs::UNKNOWN_CLIPPY_LINTS,
674         attrs::USELESS_ATTRIBUTE,
675         bit_mask::BAD_BIT_MASK,
676         bit_mask::INEFFECTIVE_BIT_MASK,
677         bit_mask::VERBOSE_BIT_MASK,
678         blacklisted_name::BLACKLISTED_NAME,
679         block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
680         block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
681         booleans::LOGIC_BUG,
682         booleans::NONMINIMAL_BOOL,
683         bytecount::NAIVE_BYTECOUNT,
684         cognitive_complexity::COGNITIVE_COMPLEXITY,
685         collapsible_if::COLLAPSIBLE_IF,
686         const_static_lifetime::CONST_STATIC_LIFETIME,
687         copies::IFS_SAME_COND,
688         copies::IF_SAME_THEN_ELSE,
689         derive::DERIVE_HASH_XOR_EQ,
690         double_comparison::DOUBLE_COMPARISONS,
691         double_parens::DOUBLE_PARENS,
692         drop_bounds::DROP_BOUNDS,
693         drop_forget_ref::DROP_COPY,
694         drop_forget_ref::DROP_REF,
695         drop_forget_ref::FORGET_COPY,
696         drop_forget_ref::FORGET_REF,
697         duration_subsec::DURATION_SUBSEC,
698         entry::MAP_ENTRY,
699         enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
700         enum_variants::ENUM_VARIANT_NAMES,
701         enum_variants::MODULE_INCEPTION,
702         eq_op::EQ_OP,
703         eq_op::OP_REF,
704         erasing_op::ERASING_OP,
705         escape::BOXED_LOCAL,
706         eta_reduction::REDUNDANT_CLOSURE,
707         eval_order_dependence::DIVERGING_SUB_EXPRESSION,
708         eval_order_dependence::EVAL_ORDER_DEPENDENCE,
709         excessive_precision::EXCESSIVE_PRECISION,
710         explicit_write::EXPLICIT_WRITE,
711         format::USELESS_FORMAT,
712         formatting::POSSIBLE_MISSING_COMMA,
713         formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
714         formatting::SUSPICIOUS_ELSE_FORMATTING,
715         functions::NOT_UNSAFE_PTR_ARG_DEREF,
716         functions::TOO_MANY_ARGUMENTS,
717         get_last_with_len::GET_LAST_WITH_LEN,
718         identity_conversion::IDENTITY_CONVERSION,
719         identity_op::IDENTITY_OP,
720         indexing_slicing::OUT_OF_BOUNDS_INDEXING,
721         infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
722         infinite_iter::INFINITE_ITER,
723         inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
724         int_plus_one::INT_PLUS_ONE,
725         invalid_ref::INVALID_REF,
726         large_enum_variant::LARGE_ENUM_VARIANT,
727         len_zero::LEN_WITHOUT_IS_EMPTY,
728         len_zero::LEN_ZERO,
729         let_if_seq::USELESS_LET_IF_SEQ,
730         lifetimes::EXTRA_UNUSED_LIFETIMES,
731         lifetimes::NEEDLESS_LIFETIMES,
732         literal_representation::INCONSISTENT_DIGIT_GROUPING,
733         literal_representation::MISTYPED_LITERAL_SUFFIXES,
734         literal_representation::UNREADABLE_LITERAL,
735         loops::EMPTY_LOOP,
736         loops::EXPLICIT_COUNTER_LOOP,
737         loops::FOR_KV_MAP,
738         loops::FOR_LOOP_OVER_OPTION,
739         loops::FOR_LOOP_OVER_RESULT,
740         loops::ITER_NEXT_LOOP,
741         loops::MANUAL_MEMCPY,
742         loops::MUT_RANGE_BOUND,
743         loops::NEEDLESS_COLLECT,
744         loops::NEEDLESS_RANGE_LOOP,
745         loops::NEVER_LOOP,
746         loops::REVERSE_RANGE_LOOP,
747         loops::UNUSED_COLLECT,
748         loops::WHILE_IMMUTABLE_CONDITION,
749         loops::WHILE_LET_LOOP,
750         loops::WHILE_LET_ON_ITERATOR,
751         map_clone::MAP_CLONE,
752         map_unit_fn::OPTION_MAP_UNIT_FN,
753         map_unit_fn::RESULT_MAP_UNIT_FN,
754         matches::MATCH_AS_REF,
755         matches::MATCH_BOOL,
756         matches::MATCH_OVERLAPPING_ARM,
757         matches::MATCH_REF_PATS,
758         matches::MATCH_WILD_ERR_ARM,
759         matches::SINGLE_MATCH,
760         mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
761         mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
762         methods::CHARS_LAST_CMP,
763         methods::CHARS_NEXT_CMP,
764         methods::CLONE_DOUBLE_REF,
765         methods::CLONE_ON_COPY,
766         methods::EXPECT_FUN_CALL,
767         methods::FILTER_NEXT,
768         methods::INTO_ITER_ON_ARRAY,
769         methods::INTO_ITER_ON_REF,
770         methods::ITER_CLONED_COLLECT,
771         methods::ITER_NTH,
772         methods::ITER_SKIP_NEXT,
773         methods::NEW_RET_NO_SELF,
774         methods::OK_EXPECT,
775         methods::OPTION_MAP_OR_NONE,
776         methods::OR_FUN_CALL,
777         methods::SEARCH_IS_SOME,
778         methods::SHOULD_IMPLEMENT_TRAIT,
779         methods::SINGLE_CHAR_PATTERN,
780         methods::STRING_EXTEND_CHARS,
781         methods::TEMPORARY_CSTRING_AS_PTR,
782         methods::UNNECESSARY_FILTER_MAP,
783         methods::UNNECESSARY_FOLD,
784         methods::USELESS_ASREF,
785         methods::WRONG_SELF_CONVENTION,
786         minmax::MIN_MAX,
787         misc::CMP_NAN,
788         misc::CMP_OWNED,
789         misc::FLOAT_CMP,
790         misc::MODULO_ONE,
791         misc::REDUNDANT_PATTERN,
792         misc::SHORT_CIRCUIT_STATEMENT,
793         misc::TOPLEVEL_REF_ARG,
794         misc::ZERO_PTR,
795         misc_early::BUILTIN_TYPE_SHADOW,
796         misc_early::DOUBLE_NEG,
797         misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
798         misc_early::MIXED_CASE_HEX_LITERALS,
799         misc_early::REDUNDANT_CLOSURE_CALL,
800         misc_early::UNNEEDED_FIELD_PATTERN,
801         misc_early::ZERO_PREFIXED_LITERAL,
802         mut_reference::UNNECESSARY_MUT_PASSED,
803         mutex_atomic::MUTEX_ATOMIC,
804         needless_bool::BOOL_COMPARISON,
805         needless_bool::NEEDLESS_BOOL,
806         needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
807         needless_update::NEEDLESS_UPDATE,
808         neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
809         neg_multiply::NEG_MULTIPLY,
810         new_without_default::NEW_WITHOUT_DEFAULT,
811         no_effect::NO_EFFECT,
812         no_effect::UNNECESSARY_OPERATION,
813         non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
814         non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
815         non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
816         non_expressive_names::MANY_SINGLE_CHAR_NAMES,
817         ok_if_let::IF_LET_SOME_RESULT,
818         open_options::NONSENSICAL_OPEN_OPTIONS,
819         overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
820         panic_unimplemented::PANIC_PARAMS,
821         partialeq_ne_impl::PARTIALEQ_NE_IMPL,
822         precedence::PRECEDENCE,
823         ptr::CMP_NULL,
824         ptr::MUT_FROM_REF,
825         ptr::PTR_ARG,
826         ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
827         question_mark::QUESTION_MARK,
828         ranges::ITERATOR_STEP_BY_ZERO,
829         ranges::RANGE_MINUS_ONE,
830         ranges::RANGE_PLUS_ONE,
831         ranges::RANGE_ZIP_WITH_LEN,
832         redundant_field_names::REDUNDANT_FIELD_NAMES,
833         redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
834         reference::DEREF_ADDROF,
835         reference::REF_IN_DEREF,
836         regex::INVALID_REGEX,
837         regex::REGEX_MACRO,
838         regex::TRIVIAL_REGEX,
839         returns::LET_AND_RETURN,
840         returns::NEEDLESS_RETURN,
841         returns::UNUSED_UNIT,
842         serde_api::SERDE_API_MISUSE,
843         slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
844         strings::STRING_LIT_AS_BYTES,
845         suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
846         suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
847         swap::ALMOST_SWAPPED,
848         swap::MANUAL_SWAP,
849         temporary_assignment::TEMPORARY_ASSIGNMENT,
850         transmute::CROSSPOINTER_TRANSMUTE,
851         transmute::TRANSMUTE_BYTES_TO_STR,
852         transmute::TRANSMUTE_INT_TO_BOOL,
853         transmute::TRANSMUTE_INT_TO_CHAR,
854         transmute::TRANSMUTE_INT_TO_FLOAT,
855         transmute::TRANSMUTE_PTR_TO_PTR,
856         transmute::TRANSMUTE_PTR_TO_REF,
857         transmute::USELESS_TRANSMUTE,
858         transmute::WRONG_TRANSMUTE,
859         transmuting_null::TRANSMUTING_NULL,
860         trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
861         types::ABSURD_EXTREME_COMPARISONS,
862         types::BORROWED_BOX,
863         types::BOX_VEC,
864         types::CAST_LOSSLESS,
865         types::CAST_PTR_ALIGNMENT,
866         types::CAST_REF_TO_MUT,
867         types::CHAR_LIT_AS_U8,
868         types::FN_TO_NUMERIC_CAST,
869         types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
870         types::IMPLICIT_HASHER,
871         types::LET_UNIT_VALUE,
872         types::OPTION_OPTION,
873         types::TYPE_COMPLEXITY,
874         types::UNIT_ARG,
875         types::UNIT_CMP,
876         types::UNNECESSARY_CAST,
877         types::VEC_BOX,
878         unicode::ZERO_WIDTH_SPACE,
879         unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
880         unused_io_amount::UNUSED_IO_AMOUNT,
881         unused_label::UNUSED_LABEL,
882         vec::USELESS_VEC,
883         write::PRINTLN_EMPTY_STRING,
884         write::PRINT_LITERAL,
885         write::PRINT_WITH_NEWLINE,
886         write::WRITELN_EMPTY_STRING,
887         write::WRITE_LITERAL,
888         write::WRITE_WITH_NEWLINE,
889         zero_div_zero::ZERO_DIVIDED_BY_ZERO,
890     ]);
891
892     reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
893         assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
894         assign_ops::ASSIGN_OP_PATTERN,
895         attrs::UNKNOWN_CLIPPY_LINTS,
896         bit_mask::VERBOSE_BIT_MASK,
897         blacklisted_name::BLACKLISTED_NAME,
898         block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
899         block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
900         collapsible_if::COLLAPSIBLE_IF,
901         const_static_lifetime::CONST_STATIC_LIFETIME,
902         enum_variants::ENUM_VARIANT_NAMES,
903         enum_variants::MODULE_INCEPTION,
904         eq_op::OP_REF,
905         eta_reduction::REDUNDANT_CLOSURE,
906         excessive_precision::EXCESSIVE_PRECISION,
907         formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
908         formatting::SUSPICIOUS_ELSE_FORMATTING,
909         infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
910         len_zero::LEN_WITHOUT_IS_EMPTY,
911         len_zero::LEN_ZERO,
912         let_if_seq::USELESS_LET_IF_SEQ,
913         literal_representation::INCONSISTENT_DIGIT_GROUPING,
914         literal_representation::UNREADABLE_LITERAL,
915         loops::EMPTY_LOOP,
916         loops::FOR_KV_MAP,
917         loops::NEEDLESS_RANGE_LOOP,
918         loops::WHILE_LET_ON_ITERATOR,
919         map_clone::MAP_CLONE,
920         matches::MATCH_BOOL,
921         matches::MATCH_OVERLAPPING_ARM,
922         matches::MATCH_REF_PATS,
923         matches::MATCH_WILD_ERR_ARM,
924         matches::SINGLE_MATCH,
925         mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
926         methods::CHARS_LAST_CMP,
927         methods::INTO_ITER_ON_REF,
928         methods::ITER_CLONED_COLLECT,
929         methods::ITER_SKIP_NEXT,
930         methods::NEW_RET_NO_SELF,
931         methods::OK_EXPECT,
932         methods::OPTION_MAP_OR_NONE,
933         methods::SHOULD_IMPLEMENT_TRAIT,
934         methods::STRING_EXTEND_CHARS,
935         methods::UNNECESSARY_FOLD,
936         methods::WRONG_SELF_CONVENTION,
937         misc::REDUNDANT_PATTERN,
938         misc::TOPLEVEL_REF_ARG,
939         misc::ZERO_PTR,
940         misc_early::BUILTIN_TYPE_SHADOW,
941         misc_early::DOUBLE_NEG,
942         misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
943         misc_early::MIXED_CASE_HEX_LITERALS,
944         misc_early::UNNEEDED_FIELD_PATTERN,
945         mut_reference::UNNECESSARY_MUT_PASSED,
946         neg_multiply::NEG_MULTIPLY,
947         new_without_default::NEW_WITHOUT_DEFAULT,
948         non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
949         non_expressive_names::MANY_SINGLE_CHAR_NAMES,
950         ok_if_let::IF_LET_SOME_RESULT,
951         panic_unimplemented::PANIC_PARAMS,
952         ptr::CMP_NULL,
953         ptr::PTR_ARG,
954         question_mark::QUESTION_MARK,
955         redundant_field_names::REDUNDANT_FIELD_NAMES,
956         redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
957         regex::REGEX_MACRO,
958         regex::TRIVIAL_REGEX,
959         returns::LET_AND_RETURN,
960         returns::NEEDLESS_RETURN,
961         returns::UNUSED_UNIT,
962         strings::STRING_LIT_AS_BYTES,
963         types::FN_TO_NUMERIC_CAST,
964         types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
965         types::IMPLICIT_HASHER,
966         types::LET_UNIT_VALUE,
967         unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
968         write::PRINTLN_EMPTY_STRING,
969         write::PRINT_LITERAL,
970         write::PRINT_WITH_NEWLINE,
971         write::WRITELN_EMPTY_STRING,
972         write::WRITE_LITERAL,
973         write::WRITE_WITH_NEWLINE,
974     ]);
975
976     reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
977         assign_ops::MISREFACTORED_ASSIGN_OP,
978         attrs::DEPRECATED_CFG_ATTR,
979         booleans::NONMINIMAL_BOOL,
980         cognitive_complexity::COGNITIVE_COMPLEXITY,
981         double_comparison::DOUBLE_COMPARISONS,
982         double_parens::DOUBLE_PARENS,
983         duration_subsec::DURATION_SUBSEC,
984         eval_order_dependence::DIVERGING_SUB_EXPRESSION,
985         eval_order_dependence::EVAL_ORDER_DEPENDENCE,
986         explicit_write::EXPLICIT_WRITE,
987         format::USELESS_FORMAT,
988         functions::TOO_MANY_ARGUMENTS,
989         get_last_with_len::GET_LAST_WITH_LEN,
990         identity_conversion::IDENTITY_CONVERSION,
991         identity_op::IDENTITY_OP,
992         int_plus_one::INT_PLUS_ONE,
993         lifetimes::EXTRA_UNUSED_LIFETIMES,
994         lifetimes::NEEDLESS_LIFETIMES,
995         loops::EXPLICIT_COUNTER_LOOP,
996         loops::MUT_RANGE_BOUND,
997         loops::WHILE_LET_LOOP,
998         map_unit_fn::OPTION_MAP_UNIT_FN,
999         map_unit_fn::RESULT_MAP_UNIT_FN,
1000         matches::MATCH_AS_REF,
1001         methods::CHARS_NEXT_CMP,
1002         methods::CLONE_ON_COPY,
1003         methods::FILTER_NEXT,
1004         methods::SEARCH_IS_SOME,
1005         methods::UNNECESSARY_FILTER_MAP,
1006         methods::USELESS_ASREF,
1007         misc::SHORT_CIRCUIT_STATEMENT,
1008         misc_early::REDUNDANT_CLOSURE_CALL,
1009         misc_early::ZERO_PREFIXED_LITERAL,
1010         needless_bool::BOOL_COMPARISON,
1011         needless_bool::NEEDLESS_BOOL,
1012         needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
1013         needless_update::NEEDLESS_UPDATE,
1014         neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
1015         no_effect::NO_EFFECT,
1016         no_effect::UNNECESSARY_OPERATION,
1017         overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
1018         partialeq_ne_impl::PARTIALEQ_NE_IMPL,
1019         precedence::PRECEDENCE,
1020         ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
1021         ranges::RANGE_MINUS_ONE,
1022         ranges::RANGE_PLUS_ONE,
1023         ranges::RANGE_ZIP_WITH_LEN,
1024         reference::DEREF_ADDROF,
1025         reference::REF_IN_DEREF,
1026         swap::MANUAL_SWAP,
1027         temporary_assignment::TEMPORARY_ASSIGNMENT,
1028         transmute::CROSSPOINTER_TRANSMUTE,
1029         transmute::TRANSMUTE_BYTES_TO_STR,
1030         transmute::TRANSMUTE_INT_TO_BOOL,
1031         transmute::TRANSMUTE_INT_TO_CHAR,
1032         transmute::TRANSMUTE_INT_TO_FLOAT,
1033         transmute::TRANSMUTE_PTR_TO_PTR,
1034         transmute::TRANSMUTE_PTR_TO_REF,
1035         transmute::USELESS_TRANSMUTE,
1036         types::BORROWED_BOX,
1037         types::CAST_LOSSLESS,
1038         types::CHAR_LIT_AS_U8,
1039         types::OPTION_OPTION,
1040         types::TYPE_COMPLEXITY,
1041         types::UNIT_ARG,
1042         types::UNNECESSARY_CAST,
1043         types::VEC_BOX,
1044         unused_label::UNUSED_LABEL,
1045         zero_div_zero::ZERO_DIVIDED_BY_ZERO,
1046     ]);
1047
1048     reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
1049         approx_const::APPROX_CONSTANT,
1050         attrs::DEPRECATED_SEMVER,
1051         attrs::USELESS_ATTRIBUTE,
1052         bit_mask::BAD_BIT_MASK,
1053         bit_mask::INEFFECTIVE_BIT_MASK,
1054         booleans::LOGIC_BUG,
1055         copies::IFS_SAME_COND,
1056         copies::IF_SAME_THEN_ELSE,
1057         derive::DERIVE_HASH_XOR_EQ,
1058         drop_bounds::DROP_BOUNDS,
1059         drop_forget_ref::DROP_COPY,
1060         drop_forget_ref::DROP_REF,
1061         drop_forget_ref::FORGET_COPY,
1062         drop_forget_ref::FORGET_REF,
1063         enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
1064         eq_op::EQ_OP,
1065         erasing_op::ERASING_OP,
1066         formatting::POSSIBLE_MISSING_COMMA,
1067         functions::NOT_UNSAFE_PTR_ARG_DEREF,
1068         indexing_slicing::OUT_OF_BOUNDS_INDEXING,
1069         infinite_iter::INFINITE_ITER,
1070         inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
1071         invalid_ref::INVALID_REF,
1072         literal_representation::MISTYPED_LITERAL_SUFFIXES,
1073         loops::FOR_LOOP_OVER_OPTION,
1074         loops::FOR_LOOP_OVER_RESULT,
1075         loops::ITER_NEXT_LOOP,
1076         loops::NEVER_LOOP,
1077         loops::REVERSE_RANGE_LOOP,
1078         loops::WHILE_IMMUTABLE_CONDITION,
1079         mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
1080         methods::CLONE_DOUBLE_REF,
1081         methods::INTO_ITER_ON_ARRAY,
1082         methods::TEMPORARY_CSTRING_AS_PTR,
1083         minmax::MIN_MAX,
1084         misc::CMP_NAN,
1085         misc::FLOAT_CMP,
1086         misc::MODULO_ONE,
1087         non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
1088         non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
1089         open_options::NONSENSICAL_OPEN_OPTIONS,
1090         ptr::MUT_FROM_REF,
1091         ranges::ITERATOR_STEP_BY_ZERO,
1092         regex::INVALID_REGEX,
1093         serde_api::SERDE_API_MISUSE,
1094         suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
1095         suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
1096         swap::ALMOST_SWAPPED,
1097         transmute::WRONG_TRANSMUTE,
1098         transmuting_null::TRANSMUTING_NULL,
1099         types::ABSURD_EXTREME_COMPARISONS,
1100         types::CAST_PTR_ALIGNMENT,
1101         types::CAST_REF_TO_MUT,
1102         types::UNIT_CMP,
1103         unicode::ZERO_WIDTH_SPACE,
1104         unused_io_amount::UNUSED_IO_AMOUNT,
1105     ]);
1106
1107     reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
1108         bytecount::NAIVE_BYTECOUNT,
1109         entry::MAP_ENTRY,
1110         escape::BOXED_LOCAL,
1111         large_enum_variant::LARGE_ENUM_VARIANT,
1112         loops::MANUAL_MEMCPY,
1113         loops::NEEDLESS_COLLECT,
1114         loops::UNUSED_COLLECT,
1115         methods::EXPECT_FUN_CALL,
1116         methods::ITER_NTH,
1117         methods::OR_FUN_CALL,
1118         methods::SINGLE_CHAR_PATTERN,
1119         misc::CMP_OWNED,
1120         mutex_atomic::MUTEX_ATOMIC,
1121         slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
1122         trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
1123         types::BOX_VEC,
1124         vec::USELESS_VEC,
1125     ]);
1126
1127     reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
1128         cargo_common_metadata::CARGO_COMMON_METADATA,
1129         multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
1130         wildcard_dependencies::WILDCARD_DEPENDENCIES,
1131     ]);
1132
1133     reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
1134         attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
1135         fallible_impl_from::FALLIBLE_IMPL_FROM,
1136         missing_const_for_fn::MISSING_CONST_FOR_FN,
1137         mutex_atomic::MUTEX_INTEGER,
1138         needless_borrow::NEEDLESS_BORROW,
1139         path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE,
1140         redundant_clone::REDUNDANT_CLONE,
1141         unwrap::PANICKING_UNWRAP,
1142         unwrap::UNNECESSARY_UNWRAP,
1143     ]);
1144 }
1145
1146 /// Register renamed lints.
1147 ///
1148 /// Used in `./src/driver.rs`.
1149 pub fn register_renamed(ls: &mut rustc::lint::LintStore) {
1150     ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions");
1151     ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
1152     ls.register_renamed("clippy::cyclomatic_complexity", "clippy::cognitive_complexity");
1153 }
1154
1155 // only exists to let the dogfood integration test works.
1156 // Don't run clippy as an executable directly
1157 #[allow(dead_code)]
1158 fn main() {
1159     panic!("Please use the cargo-clippy executable");
1160 }