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