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