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