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