]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/lib.rs
Auto merge of #4273 - mikerite:deny-warnings, r=flip1995
[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 #![cfg_attr(feature = "deny-warnings", deny(warnings))]
13 #![feature(crate_visibility_modifier)]
14 #![feature(concat_idents)]
15
16 // FIXME: switch to something more ergonomic here, once available.
17 // (Currently there is no way to opt into sysroot crates without `extern crate`.)
18 #[allow(unused_extern_crates)]
19 extern crate fmt_macros;
20 #[allow(unused_extern_crates)]
21 extern crate rustc;
22 #[allow(unused_extern_crates)]
23 extern crate rustc_data_structures;
24 #[allow(unused_extern_crates)]
25 extern crate rustc_errors;
26 #[allow(unused_extern_crates)]
27 extern crate rustc_mir;
28 #[allow(unused_extern_crates)]
29 extern crate rustc_plugin;
30 #[allow(unused_extern_crates)]
31 extern crate rustc_target;
32 #[allow(unused_extern_crates)]
33 extern crate rustc_typeck;
34 #[allow(unused_extern_crates)]
35 extern crate syntax;
36 #[allow(unused_extern_crates)]
37 extern crate syntax_pos;
38
39 use toml;
40
41 /// Macro used to declare a Clippy lint.
42 ///
43 /// Every lint declaration consists of 4 parts:
44 ///
45 /// 1. The documentation, which is used for the website
46 /// 2. The `LINT_NAME`. See [lint naming][lint_naming] on lint naming conventions.
47 /// 3. The `lint_level`, which is a mapping from *one* of our lint groups to `Allow`, `Warn` or
48 ///    `Deny`. The lint level here has nothing to do with what lint groups the lint is a part of.
49 /// 4. The `description` that contains a short explanation on what's wrong with code where the
50 ///    lint is triggered.
51 ///
52 /// Currently the categories `style`, `correctness`, `complexity` and `perf` are enabled by default.
53 /// As said in the README.md of this repository, if the lint level mapping changes, please update
54 /// README.md.
55 ///
56 /// # Example
57 ///
58 /// ```
59 /// # #![feature(rustc_private)]
60 /// # #[allow(unused_extern_crates)]
61 /// # extern crate rustc;
62 /// # #[macro_use]
63 /// # use clippy_lints::declare_clippy_lint;
64 /// use rustc::declare_tool_lint;
65 ///
66 /// declare_clippy_lint! {
67 ///     /// **What it does:** Checks for ... (describe what the lint matches).
68 ///     ///
69 ///     /// **Why is this bad?** Supply the reason for linting the code.
70 ///     ///
71 ///     /// **Known problems:** None. (Or describe where it could go wrong.)
72 ///     ///
73 ///     /// **Example:**
74 ///     ///
75 ///     /// ```rust
76 ///     /// // Bad
77 ///     /// Insert a short example of code that triggers the lint
78 ///     ///
79 ///     /// // Good
80 ///     /// Insert a short example of improved code that doesn't trigger the lint
81 ///     /// ```
82 ///     pub LINT_NAME,
83 ///     pedantic,
84 ///     "description"
85 /// }
86 /// ```
87 /// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
88 #[macro_export]
89 macro_rules! declare_clippy_lint {
90     { $(#[$attr:meta])* pub $name:tt, style, $description:tt } => {
91         declare_tool_lint! {
92             $(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
93         }
94     };
95     { $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => {
96         declare_tool_lint! {
97             $(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
98         }
99     };
100     { $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
101         declare_tool_lint! {
102             pub clippy::$name, Warn, $description, report_in_external_macro: true
103         }
104     };
105     { $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => {
106         declare_tool_lint! {
107             pub clippy::$name, Warn, $description, report_in_external_macro: true
108         }
109     };
110     { $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => {
111         declare_tool_lint! {
112             pub clippy::$name, Allow, $description, report_in_external_macro: true
113         }
114     };
115     { $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
116         declare_tool_lint! {
117             pub clippy::$name, Allow, $description, report_in_external_macro: true
118         }
119     };
120     { $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
121         declare_tool_lint! {
122             pub clippy::$name, Allow, $description, report_in_external_macro: true
123         }
124     };
125     { $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => {
126         declare_tool_lint! {
127             pub clippy::$name, Allow, $description, report_in_external_macro: true
128         }
129     };
130     { $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => {
131         declare_tool_lint! {
132             pub clippy::$name, Allow, $description, report_in_external_macro: true
133         }
134     };
135     { $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => {
136         declare_tool_lint! {
137             pub clippy::$name, Warn, $description, report_in_external_macro: true
138         }
139     };
140 }
141
142 mod consts;
143 #[macro_use]
144 mod utils;
145
146 // begin lints modules, do not remove this comment, it’s used in `update_lints`
147 pub mod approx_const;
148 pub mod arithmetic;
149 pub mod assertions_on_constants;
150 pub mod assign_ops;
151 pub mod attrs;
152 pub mod bit_mask;
153 pub mod blacklisted_name;
154 pub mod block_in_if_condition;
155 pub mod booleans;
156 pub mod bytecount;
157 pub mod cargo_common_metadata;
158 pub mod checked_conversions;
159 pub mod cognitive_complexity;
160 pub mod collapsible_if;
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 integer_division;
201 pub mod invalid_ref;
202 pub mod items_after_statements;
203 pub mod large_enum_variant;
204 pub mod len_zero;
205 pub mod let_if_seq;
206 pub mod lifetimes;
207 pub mod literal_representation;
208 pub mod loops;
209 pub mod map_clone;
210 pub mod map_unit_fn;
211 pub mod matches;
212 pub mod mem_discriminant;
213 pub mod mem_forget;
214 pub mod mem_replace;
215 pub mod methods;
216 pub mod minmax;
217 pub mod misc;
218 pub mod misc_early;
219 pub mod missing_const_for_fn;
220 pub mod missing_doc;
221 pub mod missing_inline;
222 pub mod multiple_crate_versions;
223 pub mod mut_mut;
224 pub mod mut_reference;
225 pub mod mutex_atomic;
226 pub mod needless_bool;
227 pub mod needless_borrow;
228 pub mod needless_borrowed_ref;
229 pub mod needless_continue;
230 pub mod needless_pass_by_value;
231 pub mod needless_update;
232 pub mod neg_cmp_op_on_partial_ord;
233 pub mod neg_multiply;
234 pub mod new_without_default;
235 pub mod no_effect;
236 pub mod non_copy_const;
237 pub mod non_expressive_names;
238 pub mod ok_if_let;
239 pub mod open_options;
240 pub mod overflow_check_conditional;
241 pub mod panic_unimplemented;
242 pub mod partialeq_ne_impl;
243 pub mod path_buf_push_overwrite;
244 pub mod precedence;
245 pub mod ptr;
246 pub mod ptr_offset_with_cast;
247 pub mod question_mark;
248 pub mod ranges;
249 pub mod redundant_clone;
250 pub mod redundant_field_names;
251 pub mod redundant_pattern_matching;
252 pub mod redundant_static_lifetimes;
253 pub mod reference;
254 pub mod regex;
255 pub mod replace_consts;
256 pub mod returns;
257 pub mod serde_api;
258 pub mod shadow;
259 pub mod slow_vector_initialization;
260 pub mod strings;
261 pub mod suspicious_trait_impl;
262 pub mod swap;
263 pub mod temporary_assignment;
264 pub mod transmute;
265 pub mod transmuting_null;
266 pub mod trivially_copy_pass_by_ref;
267 pub mod try_err;
268 pub mod types;
269 pub mod unicode;
270 pub mod unsafe_removed_from_name;
271 pub mod unused_io_amount;
272 pub mod unused_label;
273 pub mod unwrap;
274 pub mod use_self;
275 pub mod vec;
276 pub mod wildcard_dependencies;
277 pub mod write;
278 pub mod zero_div_zero;
279 // end lints modules, do not remove this comment, it’s used in `update_lints`
280
281 pub use crate::utils::conf::Conf;
282
283 mod reexport {
284     crate use syntax::ast::Name;
285 }
286
287 /// Register all pre expansion lints
288 ///
289 /// Pre-expansion lints run before any macro expansion has happened.
290 ///
291 /// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
292 /// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
293 ///
294 /// Used in `./src/driver.rs`.
295 pub fn register_pre_expansion_lints(
296     session: &rustc::session::Session,
297     store: &mut rustc::lint::LintStore,
298     conf: &Conf,
299 ) {
300     store.register_pre_expansion_pass(Some(session), true, false, box write::Write);
301     store.register_pre_expansion_pass(
302         Some(session),
303         true,
304         false,
305         box redundant_field_names::RedundantFieldNames,
306     );
307     store.register_pre_expansion_pass(
308         Some(session),
309         true,
310         false,
311         box non_expressive_names::NonExpressiveNames {
312             single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
313         },
314     );
315     store.register_pre_expansion_pass(Some(session), true, false, box attrs::DeprecatedCfgAttribute);
316     store.register_pre_expansion_pass(Some(session), true, false, box dbg_macro::DbgMacro);
317 }
318
319 #[doc(hidden)]
320 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
321     match utils::conf::file_from_args(reg.args()) {
322         Ok(file_name) => {
323             // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
324             // do not require the file to exist
325             let file_name = if let Some(file_name) = file_name {
326                 Some(file_name)
327             } else {
328                 match utils::conf::lookup_conf_file() {
329                     Ok(path) => path,
330                     Err(error) => {
331                         reg.sess
332                             .struct_err(&format!("error finding Clippy's configuration file: {}", error))
333                             .emit();
334                         None
335                     },
336                 }
337             };
338
339             let file_name = file_name.map(|file_name| {
340                 if file_name.is_relative() {
341                     reg.sess
342                         .local_crate_source_file
343                         .as_ref()
344                         .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
345                         .unwrap_or_default()
346                         .join(file_name)
347                 } else {
348                     file_name
349                 }
350             });
351
352             let (conf, errors) = utils::conf::read(file_name.as_ref().map(std::convert::AsRef::as_ref));
353
354             // all conf errors are non-fatal, we just use the default conf in case of error
355             for error in errors {
356                 reg.sess
357                     .struct_err(&format!(
358                         "error reading Clippy's configuration file `{}`: {}",
359                         file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""),
360                         error
361                     ))
362                     .emit();
363             }
364
365             conf
366         },
367         Err((err, span)) => {
368             reg.sess
369                 .struct_span_err(span, err)
370                 .span_note(span, "Clippy will use default configuration")
371                 .emit();
372             toml::from_str("").expect("we never error on empty config files")
373         },
374     }
375 }
376
377 /// Register all lints and lint groups with the rustc plugin registry
378 ///
379 /// Used in `./src/driver.rs`.
380 #[allow(clippy::too_many_lines)]
381 #[rustfmt::skip]
382 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
383     let mut store = reg.sess.lint_store.borrow_mut();
384     // begin deprecated lints, do not remove this comment, it’s used in `update_lints`
385     store.register_removed(
386         "should_assert_eq",
387         "`assert!()` will be more flexible with RFC 2011",
388     );
389     store.register_removed(
390         "extend_from_slice",
391         "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
392     );
393     store.register_removed(
394         "range_step_by_zero",
395         "`iterator.step_by(0)` panics nowadays",
396     );
397     store.register_removed(
398         "unstable_as_slice",
399         "`Vec::as_slice` has been stabilized in 1.7",
400     );
401     store.register_removed(
402         "unstable_as_mut_slice",
403         "`Vec::as_mut_slice` has been stabilized in 1.7",
404     );
405     store.register_removed(
406         "str_to_string",
407         "using `str::to_string` is common even today and specialization will likely happen soon",
408     );
409     store.register_removed(
410         "string_to_string",
411         "using `string::to_string` is common even today and specialization will likely happen soon",
412     );
413     store.register_removed(
414         "misaligned_transmute",
415         "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
416     );
417     store.register_removed(
418         "assign_ops",
419         "using compound assignment operators (e.g., `+=`) is harmless",
420     );
421     store.register_removed(
422         "if_let_redundant_pattern_matching",
423         "this lint has been changed to redundant_pattern_matching",
424     );
425     store.register_removed(
426         "unsafe_vector_initialization",
427         "the replacement suggested by this lint had substantially different behavior",
428     );
429     // end deprecated lints, do not remove this comment, it’s used in `update_lints`
430
431     reg.register_late_lint_pass(box serde_api::SerdeAPI);
432     reg.register_early_lint_pass(box utils::internal_lints::ClippyLintsInternal);
433     reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
434     reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
435     reg.register_late_lint_pass(box utils::internal_lints::OuterExpnInfoPass);
436     reg.register_late_lint_pass(box utils::inspector::DeepCodeInspector);
437     reg.register_late_lint_pass(box utils::author::Author);
438     reg.register_late_lint_pass(box types::Types);
439     reg.register_late_lint_pass(box booleans::NonminimalBool);
440     reg.register_late_lint_pass(box eq_op::EqOp);
441     reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
442     reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
443     reg.register_late_lint_pass(box enum_clike::UnportableVariant);
444     reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
445     reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
446     reg.register_late_lint_pass(box ptr::Ptr);
447     reg.register_late_lint_pass(box needless_bool::NeedlessBool);
448     reg.register_late_lint_pass(box needless_bool::BoolComparison);
449     reg.register_late_lint_pass(box approx_const::ApproxConstant);
450     reg.register_late_lint_pass(box misc::MiscLints);
451     reg.register_early_lint_pass(box precedence::Precedence);
452     reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
453     reg.register_late_lint_pass(box eta_reduction::EtaReduction);
454     reg.register_late_lint_pass(box identity_op::IdentityOp);
455     reg.register_late_lint_pass(box erasing_op::ErasingOp);
456     reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
457     reg.register_late_lint_pass(box mut_mut::MutMut);
458     reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
459     reg.register_late_lint_pass(box len_zero::LenZero);
460     reg.register_late_lint_pass(box attrs::Attributes);
461     reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
462     reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
463     reg.register_late_lint_pass(box unicode::Unicode);
464     reg.register_late_lint_pass(box strings::StringAdd);
465     reg.register_early_lint_pass(box returns::Return);
466     reg.register_late_lint_pass(box implicit_return::ImplicitReturn);
467     reg.register_late_lint_pass(box methods::Methods);
468     reg.register_late_lint_pass(box map_clone::MapClone);
469     reg.register_late_lint_pass(box shadow::Shadow);
470     reg.register_late_lint_pass(box types::LetUnitValue);
471     reg.register_late_lint_pass(box types::UnitCmp);
472     reg.register_late_lint_pass(box loops::Loops);
473     reg.register_late_lint_pass(box lifetimes::Lifetimes);
474     reg.register_late_lint_pass(box entry::HashMapPass);
475     reg.register_late_lint_pass(box ranges::Ranges);
476     reg.register_late_lint_pass(box types::Casts);
477     reg.register_late_lint_pass(box types::TypeComplexity::new(conf.type_complexity_threshold));
478     reg.register_late_lint_pass(box matches::Matches);
479     reg.register_late_lint_pass(box minmax::MinMaxPass);
480     reg.register_late_lint_pass(box open_options::OpenOptions);
481     reg.register_late_lint_pass(box zero_div_zero::ZeroDiv);
482     reg.register_late_lint_pass(box mutex_atomic::Mutex);
483     reg.register_late_lint_pass(box needless_update::NeedlessUpdate);
484     reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow::default());
485     reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
486     reg.register_late_lint_pass(box no_effect::NoEffect);
487     reg.register_late_lint_pass(box temporary_assignment::TemporaryAssignment);
488     reg.register_late_lint_pass(box transmute::Transmute);
489     reg.register_late_lint_pass(
490         box cognitive_complexity::CognitiveComplexity::new(conf.cognitive_complexity_threshold)
491     );
492     reg.register_late_lint_pass(box escape::BoxedLocal{too_large_for_stack: conf.too_large_for_stack});
493     reg.register_early_lint_pass(box misc_early::MiscEarlyLints);
494     reg.register_late_lint_pass(box panic_unimplemented::PanicUnimplemented);
495     reg.register_late_lint_pass(box strings::StringLitAsBytes);
496     reg.register_late_lint_pass(box derive::Derive);
497     reg.register_late_lint_pass(box types::CharLitAsU8);
498     reg.register_late_lint_pass(box vec::UselessVec);
499     reg.register_late_lint_pass(box drop_bounds::DropBounds);
500     reg.register_late_lint_pass(box get_last_with_len::GetLastWithLen);
501     reg.register_late_lint_pass(box drop_forget_ref::DropForgetRef);
502     reg.register_late_lint_pass(box empty_enum::EmptyEnum);
503     reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
504     reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
505     reg.register_late_lint_pass(box regex::Regex::default());
506     reg.register_late_lint_pass(box copies::CopyAndPaste);
507     reg.register_late_lint_pass(box copy_iterator::CopyIterator);
508     reg.register_late_lint_pass(box format::UselessFormat);
509     reg.register_early_lint_pass(box formatting::Formatting);
510     reg.register_late_lint_pass(box swap::Swap);
511     reg.register_early_lint_pass(box if_not_else::IfNotElse);
512     reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
513     reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
514     reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
515     reg.register_late_lint_pass(box unused_label::UnusedLabel);
516     reg.register_late_lint_pass(box new_without_default::NewWithoutDefault::default());
517     reg.register_late_lint_pass(box blacklisted_name::BlacklistedName::new(
518             conf.blacklisted_names.iter().cloned().collect()
519     ));
520     reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold, conf.too_many_lines_threshold));
521     reg.register_early_lint_pass(box doc::DocMarkdown::new(conf.doc_valid_idents.iter().cloned().collect()));
522     reg.register_late_lint_pass(box neg_multiply::NegMultiply);
523     reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
524     reg.register_late_lint_pass(box mem_discriminant::MemDiscriminant);
525     reg.register_late_lint_pass(box mem_forget::MemForget);
526     reg.register_late_lint_pass(box mem_replace::MemReplace);
527     reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
528     reg.register_late_lint_pass(box assign_ops::AssignOps);
529     reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
530     reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
531     reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
532     reg.register_late_lint_pass(box missing_inline::MissingInline);
533     reg.register_late_lint_pass(box ok_if_let::OkIfLet);
534     reg.register_late_lint_pass(box redundant_pattern_matching::RedundantPatternMatching);
535     reg.register_late_lint_pass(box partialeq_ne_impl::PartialEqNeImpl);
536     reg.register_early_lint_pass(box reference::DerefAddrOf);
537     reg.register_early_lint_pass(box reference::RefInDeref);
538     reg.register_early_lint_pass(box double_parens::DoubleParens);
539     reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
540     reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
541     reg.register_late_lint_pass(box explicit_write::ExplicitWrite);
542     reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
543     reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
544             conf.trivial_copy_size_limit,
545             &reg.sess.target,
546     ));
547     reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
548     reg.register_early_lint_pass(box literal_representation::DecimalLiteralRepresentation::new(
549             conf.literal_representation_threshold
550     ));
551     reg.register_late_lint_pass(box try_err::TryErr);
552     reg.register_late_lint_pass(box use_self::UseSelf);
553     reg.register_late_lint_pass(box bytecount::ByteCount);
554     reg.register_late_lint_pass(box infinite_iter::InfiniteIter);
555     reg.register_late_lint_pass(box inline_fn_without_body::InlineFnWithoutBody);
556     reg.register_late_lint_pass(box invalid_ref::InvalidRef);
557     reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
558     reg.register_late_lint_pass(box types::ImplicitHasher);
559     reg.register_early_lint_pass(box redundant_static_lifetimes::RedundantStaticLifetimes);
560     reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
561     reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
562     reg.register_late_lint_pass(box types::UnitArg);
563     reg.register_late_lint_pass(box double_comparison::DoubleComparisons);
564     reg.register_late_lint_pass(box question_mark::QuestionMark);
565     reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
566     reg.register_early_lint_pass(box cargo_common_metadata::CargoCommonMetadata);
567     reg.register_early_lint_pass(box multiple_crate_versions::MultipleCrateVersions);
568     reg.register_early_lint_pass(box wildcard_dependencies::WildcardDependencies);
569     reg.register_late_lint_pass(box map_unit_fn::MapUnit);
570     reg.register_late_lint_pass(box infallible_destructuring_match::InfallibleDestructingMatch);
571     reg.register_late_lint_pass(box inherent_impl::MultipleInherentImpl::default());
572     reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
573     reg.register_late_lint_pass(box unwrap::Unwrap);
574     reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
575     reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
576     reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
577     reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
578     reg.register_late_lint_pass(box ptr_offset_with_cast::PtrOffsetWithCast);
579     reg.register_late_lint_pass(box redundant_clone::RedundantClone);
580     reg.register_late_lint_pass(box slow_vector_initialization::SlowVectorInit);
581     reg.register_late_lint_pass(box types::RefToMut);
582     reg.register_late_lint_pass(box assertions_on_constants::AssertionsOnConstants);
583     reg.register_late_lint_pass(box missing_const_for_fn::MissingConstForFn);
584     reg.register_late_lint_pass(box transmuting_null::TransmutingNull);
585     reg.register_late_lint_pass(box path_buf_push_overwrite::PathBufPushOverwrite);
586     reg.register_late_lint_pass(box checked_conversions::CheckedConversions);
587     reg.register_late_lint_pass(box integer_division::IntegerDivision);
588
589     reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
590         arithmetic::FLOAT_ARITHMETIC,
591         arithmetic::INTEGER_ARITHMETIC,
592         dbg_macro::DBG_MACRO,
593         else_if_without_else::ELSE_IF_WITHOUT_ELSE,
594         implicit_return::IMPLICIT_RETURN,
595         indexing_slicing::INDEXING_SLICING,
596         inherent_impl::MULTIPLE_INHERENT_IMPL,
597         integer_division::INTEGER_DIVISION,
598         literal_representation::DECIMAL_LITERAL_REPRESENTATION,
599         matches::WILDCARD_ENUM_MATCH_ARM,
600         mem_forget::MEM_FORGET,
601         methods::CLONE_ON_REF_PTR,
602         methods::GET_UNWRAP,
603         methods::OPTION_UNWRAP_USED,
604         methods::RESULT_UNWRAP_USED,
605         methods::WRONG_PUB_SELF_CONVENTION,
606         misc::FLOAT_CMP_CONST,
607         missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
608         missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
609         panic_unimplemented::UNIMPLEMENTED,
610         shadow::SHADOW_REUSE,
611         shadow::SHADOW_SAME,
612         strings::STRING_ADD,
613         write::PRINT_STDOUT,
614         write::USE_DEBUG,
615     ]);
616
617     reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
618         attrs::INLINE_ALWAYS,
619         checked_conversions::CHECKED_CONVERSIONS,
620         copies::MATCH_SAME_ARMS,
621         copy_iterator::COPY_ITERATOR,
622         default_trait_access::DEFAULT_TRAIT_ACCESS,
623         derive::EXPL_IMPL_CLONE_ON_COPY,
624         doc::DOC_MARKDOWN,
625         empty_enum::EMPTY_ENUM,
626         enum_glob_use::ENUM_GLOB_USE,
627         enum_variants::MODULE_NAME_REPETITIONS,
628         enum_variants::PUB_ENUM_VARIANT_NAMES,
629         eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
630         functions::TOO_MANY_LINES,
631         if_not_else::IF_NOT_ELSE,
632         infinite_iter::MAYBE_INFINITE_ITER,
633         items_after_statements::ITEMS_AFTER_STATEMENTS,
634         literal_representation::LARGE_DIGIT_GROUPS,
635         loops::EXPLICIT_INTO_ITER_LOOP,
636         loops::EXPLICIT_ITER_LOOP,
637         matches::SINGLE_MATCH_ELSE,
638         methods::FILTER_MAP,
639         methods::FILTER_MAP_NEXT,
640         methods::FIND_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 }