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