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