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