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