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