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