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