1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 // error-pattern:cargo-clippy
12 #![feature(box_syntax)]
13 #![feature(rustc_private)]
14 #![feature(slice_patterns)]
15 #![feature(stmt_expr_attributes)]
16 #![feature(range_contains)]
17 #![feature(str_escape)]
18 #![allow(clippy::missing_docs_in_private_items)]
19 #![recursion_limit = "256"]
20 #![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)]
21 #![feature(crate_visibility_modifier)]
24 // FIXME: switch to something more ergonomic here, once available.
25 // (currently there is no way to opt into sysroot crates w/o `extern crate`)
26 #[allow(unused_extern_crates)]
27 extern crate fmt_macros;
28 #[allow(unused_extern_crates)]
30 #[allow(unused_extern_crates)]
31 extern crate rustc_data_structures;
32 #[allow(unused_extern_crates)]
33 extern crate rustc_errors;
34 #[allow(unused_extern_crates)]
35 extern crate rustc_plugin;
36 #[allow(unused_extern_crates)]
37 extern crate rustc_target;
38 #[allow(unused_extern_crates)]
39 extern crate rustc_typeck;
40 #[allow(unused_extern_crates)]
42 #[allow(unused_extern_crates)]
43 extern crate syntax_pos;
47 // Currently, categories "style", "correctness", "complexity" and "perf" are enabled by default,
48 // as said in the README.md of this repository. If this changes, please update README.md.
50 macro_rules! declare_clippy_lint {
51 { pub $name:tt, style, $description:tt } => {
52 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
54 { pub $name:tt, correctness, $description:tt } => {
55 declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true }
57 { pub $name:tt, complexity, $description:tt } => {
58 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
60 { pub $name:tt, perf, $description:tt } => {
61 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
63 { pub $name:tt, pedantic, $description:tt } => {
64 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
66 { pub $name:tt, restriction, $description:tt } => {
67 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
69 { pub $name:tt, cargo, $description:tt } => {
70 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
72 { pub $name:tt, nursery, $description:tt } => {
73 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
75 { pub $name:tt, internal, $description:tt } => {
76 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
78 { pub $name:tt, internal_warn, $description:tt } => {
79 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
87 // begin lints modules, do not remove this comment, it’s used in `update_lints`
93 pub mod blacklisted_name;
94 pub mod block_in_if_condition;
97 pub mod cargo_common_metadata;
98 pub mod collapsible_if;
99 pub mod const_static_lifetime;
101 pub mod copy_iterator;
102 pub mod cyclomatic_complexity;
103 pub mod default_trait_access;
106 pub mod double_comparison;
107 pub mod double_parens;
108 pub mod drop_forget_ref;
109 pub mod duration_subsec;
110 pub mod else_if_without_else;
114 pub mod enum_glob_use;
115 pub mod enum_variants;
119 pub mod eta_reduction;
120 pub mod eval_order_dependence;
121 pub mod excessive_precision;
122 pub mod explicit_write;
123 pub mod fallible_impl_from;
127 pub mod identity_conversion;
130 pub mod implicit_return;
131 pub mod indexing_slicing;
132 pub mod infallible_destructuring_match;
133 pub mod infinite_iter;
134 pub mod inherent_impl;
135 pub mod inline_fn_without_body;
136 pub mod int_plus_one;
138 pub mod items_after_statements;
139 pub mod large_enum_variant;
143 pub mod literal_representation;
148 pub mod mem_discriminant;
156 pub mod missing_inline;
157 pub mod multiple_crate_versions;
159 pub mod mut_reference;
160 pub mod mutex_atomic;
161 pub mod needless_bool;
162 pub mod needless_borrow;
163 pub mod needless_borrowed_ref;
164 pub mod needless_continue;
165 pub mod needless_pass_by_value;
166 pub mod needless_update;
167 pub mod neg_cmp_op_on_partial_ord;
168 pub mod neg_multiply;
169 pub mod new_without_default;
171 pub mod non_copy_const;
172 pub mod non_expressive_names;
174 pub mod open_options;
175 pub mod overflow_check_conditional;
176 pub mod panic_unimplemented;
177 pub mod partialeq_ne_impl;
180 pub mod ptr_offset_with_cast;
181 pub mod question_mark;
183 pub mod redundant_clone;
184 pub mod redundant_field_names;
185 pub mod redundant_pattern_matching;
188 pub mod replace_consts;
192 pub mod slow_vector_initialization;
194 pub mod suspicious_trait_impl;
196 pub mod temporary_assignment;
198 pub mod trivially_copy_pass_by_ref;
201 pub mod unsafe_removed_from_name;
202 pub mod unused_io_amount;
203 pub mod unused_label;
207 pub mod wildcard_dependencies;
209 pub mod zero_div_zero;
210 // end lints modules, do not remove this comment, it’s used in `update_lints`
212 pub use crate::utils::conf::Conf;
215 crate use crate::syntax::ast::{Name, NodeId};
218 pub fn register_pre_expansion_lints(
219 session: &rustc::session::Session,
220 store: &mut rustc::lint::LintStore,
223 store.register_pre_expansion_pass(Some(session), box write::Pass);
224 store.register_pre_expansion_pass(Some(session), box redundant_field_names::RedundantFieldNames);
225 store.register_pre_expansion_pass(
227 box non_expressive_names::NonExpressiveNames {
228 single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
231 store.register_pre_expansion_pass(Some(session), box attrs::CfgAttrPass);
234 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
235 match utils::conf::file_from_args(reg.args()) {
237 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
238 // do not require the file to exist
239 let file_name = if let Some(file_name) = file_name {
242 match utils::conf::lookup_conf_file() {
246 .struct_err(&format!("error finding Clippy's configuration file: {}", error))
253 let file_name = file_name.map(|file_name| {
254 if file_name.is_relative() {
256 .local_crate_source_file
258 .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
266 let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
268 // all conf errors are non-fatal, we just use the default conf in case of error
269 for error in errors {
271 .struct_err(&format!(
272 "error reading Clippy's configuration file `{}`: {}",
273 file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""),
281 Err((err, span)) => {
283 .struct_span_err(span, err)
284 .span_note(span, "Clippy will use default configuration")
286 toml::from_str("").expect("we never error on empty config files")
292 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
293 let mut store = reg.sess.lint_store.borrow_mut();
294 // begin deprecated lints, do not remove this comment, it’s used in `update_lints`
295 store.register_removed(
297 "`assert!()` will be more flexible with RFC 2011",
299 store.register_removed(
301 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
303 store.register_removed(
304 "range_step_by_zero",
305 "`iterator.step_by(0)` panics nowadays",
307 store.register_removed(
309 "`Vec::as_slice` has been stabilized in 1.7",
311 store.register_removed(
312 "unstable_as_mut_slice",
313 "`Vec::as_mut_slice` has been stabilized in 1.7",
315 store.register_removed(
317 "using `str::to_string` is common even today and specialization will likely happen soon",
319 store.register_removed(
321 "using `string::to_string` is common even today and specialization will likely happen soon",
323 store.register_removed(
324 "misaligned_transmute",
325 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
327 store.register_removed(
329 "using compound assignment operators (e.g. `+=`) is harmless",
331 store.register_removed(
332 "if_let_redundant_pattern_matching",
333 "this lint has been changed to redundant_pattern_matching",
335 store.register_removed(
336 "unsafe_vector_initialization",
337 "the replacement suggested by this lint had substantially different behavior",
339 // end deprecated lints, do not remove this comment, it’s used in `update_lints`
341 reg.register_late_lint_pass(box serde_api::Serde);
342 reg.register_early_lint_pass(box utils::internal_lints::Clippy);
343 reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
344 reg.register_early_lint_pass(box utils::internal_lints::DefaultHashTypes::default());
345 reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
346 reg.register_late_lint_pass(box utils::inspector::Pass);
347 reg.register_late_lint_pass(box utils::author::Pass);
348 reg.register_late_lint_pass(box types::TypePass);
349 reg.register_late_lint_pass(box booleans::NonminimalBool);
350 reg.register_late_lint_pass(box eq_op::EqOp);
351 reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
352 reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
353 reg.register_late_lint_pass(box enum_clike::UnportableVariant);
354 reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
355 reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
356 reg.register_late_lint_pass(box ptr::PointerPass);
357 reg.register_late_lint_pass(box needless_bool::NeedlessBool);
358 reg.register_late_lint_pass(box needless_bool::BoolComparison);
359 reg.register_late_lint_pass(box approx_const::Pass);
360 reg.register_late_lint_pass(box misc::Pass);
361 reg.register_early_lint_pass(box precedence::Precedence);
362 reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
363 reg.register_late_lint_pass(box eta_reduction::EtaPass);
364 reg.register_late_lint_pass(box identity_op::IdentityOp);
365 reg.register_late_lint_pass(box erasing_op::ErasingOp);
366 reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
367 reg.register_late_lint_pass(box mut_mut::MutMut);
368 reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
369 reg.register_late_lint_pass(box len_zero::LenZero);
370 reg.register_late_lint_pass(box attrs::AttrPass);
371 reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
372 reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
373 reg.register_late_lint_pass(box unicode::Unicode);
374 reg.register_late_lint_pass(box strings::StringAdd);
375 reg.register_early_lint_pass(box returns::ReturnPass);
376 reg.register_late_lint_pass(box implicit_return::Pass);
377 reg.register_late_lint_pass(box methods::Pass);
378 reg.register_late_lint_pass(box map_clone::Pass);
379 reg.register_late_lint_pass(box shadow::Pass);
380 reg.register_late_lint_pass(box types::LetPass);
381 reg.register_late_lint_pass(box types::UnitCmp);
382 reg.register_late_lint_pass(box loops::Pass);
383 reg.register_late_lint_pass(box lifetimes::LifetimePass);
384 reg.register_late_lint_pass(box entry::HashMapLint);
385 reg.register_late_lint_pass(box ranges::Pass);
386 reg.register_late_lint_pass(box types::CastPass);
387 reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
388 reg.register_late_lint_pass(box matches::MatchPass);
389 reg.register_late_lint_pass(box minmax::MinMaxPass);
390 reg.register_late_lint_pass(box open_options::NonSensical);
391 reg.register_late_lint_pass(box zero_div_zero::Pass);
392 reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
393 reg.register_late_lint_pass(box needless_update::Pass);
394 reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow::default());
395 reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
396 reg.register_late_lint_pass(box no_effect::Pass);
397 reg.register_late_lint_pass(box temporary_assignment::Pass);
398 reg.register_late_lint_pass(box transmute::Transmute);
399 reg.register_late_lint_pass(
400 box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
402 reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
403 reg.register_early_lint_pass(box misc_early::MiscEarly);
404 reg.register_late_lint_pass(box panic_unimplemented::Pass);
405 reg.register_late_lint_pass(box strings::StringLitAsBytes);
406 reg.register_late_lint_pass(box derive::Derive);
407 reg.register_late_lint_pass(box types::CharLitAsU8);
408 reg.register_late_lint_pass(box vec::Pass);
409 reg.register_late_lint_pass(box drop_forget_ref::Pass);
410 reg.register_late_lint_pass(box empty_enum::EmptyEnum);
411 reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
412 reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
413 reg.register_late_lint_pass(box regex::Pass::default());
414 reg.register_late_lint_pass(box copies::CopyAndPaste);
415 reg.register_late_lint_pass(box copy_iterator::CopyIterator);
416 reg.register_late_lint_pass(box format::Pass);
417 reg.register_early_lint_pass(box formatting::Formatting);
418 reg.register_late_lint_pass(box swap::Swap);
419 reg.register_early_lint_pass(box if_not_else::IfNotElse);
420 reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
421 reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
422 reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
423 reg.register_late_lint_pass(box unused_label::UnusedLabel);
424 reg.register_late_lint_pass(box new_without_default::NewWithoutDefault::default());
425 reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(conf.blacklisted_names.clone()));
426 reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold));
427 reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents.clone()));
428 reg.register_late_lint_pass(box neg_multiply::NegMultiply);
429 reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
430 reg.register_late_lint_pass(box mem_discriminant::MemDiscriminant);
431 reg.register_late_lint_pass(box mem_forget::MemForget);
432 reg.register_late_lint_pass(box mem_replace::MemReplace);
433 reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
434 reg.register_late_lint_pass(box assign_ops::AssignOps);
435 reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
436 reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
437 reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
438 reg.register_late_lint_pass(box missing_inline::MissingInline);
439 reg.register_late_lint_pass(box ok_if_let::Pass);
440 reg.register_late_lint_pass(box redundant_pattern_matching::Pass);
441 reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
442 reg.register_early_lint_pass(box reference::Pass);
443 reg.register_early_lint_pass(box reference::DerefPass);
444 reg.register_early_lint_pass(box double_parens::DoubleParens);
445 reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
446 reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
447 reg.register_late_lint_pass(box explicit_write::Pass);
448 reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
449 reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
450 conf.trivial_copy_size_limit,
453 reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
454 reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
455 conf.literal_representation_threshold
457 reg.register_late_lint_pass(box use_self::UseSelf);
458 reg.register_late_lint_pass(box bytecount::ByteCount);
459 reg.register_late_lint_pass(box infinite_iter::Pass);
460 reg.register_late_lint_pass(box inline_fn_without_body::Pass);
461 reg.register_late_lint_pass(box invalid_ref::InvalidRef);
462 reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
463 reg.register_late_lint_pass(box types::ImplicitHasher);
464 reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
465 reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
466 reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
467 reg.register_late_lint_pass(box types::UnitArg);
468 reg.register_late_lint_pass(box double_comparison::Pass);
469 reg.register_late_lint_pass(box question_mark::Pass);
470 reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
471 reg.register_early_lint_pass(box cargo_common_metadata::Pass);
472 reg.register_early_lint_pass(box multiple_crate_versions::Pass);
473 reg.register_early_lint_pass(box wildcard_dependencies::Pass);
474 reg.register_late_lint_pass(box map_unit_fn::Pass);
475 reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
476 reg.register_late_lint_pass(box inherent_impl::Pass::default());
477 reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
478 reg.register_late_lint_pass(box unwrap::Pass);
479 reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
480 reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
481 reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
482 reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
483 reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
484 reg.register_late_lint_pass(box redundant_clone::RedundantClone);
485 reg.register_late_lint_pass(box slow_vector_initialization::Pass);
487 reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
488 arithmetic::FLOAT_ARITHMETIC,
489 arithmetic::INTEGER_ARITHMETIC,
490 else_if_without_else::ELSE_IF_WITHOUT_ELSE,
491 implicit_return::IMPLICIT_RETURN,
492 indexing_slicing::INDEXING_SLICING,
493 inherent_impl::MULTIPLE_INHERENT_IMPL,
494 literal_representation::DECIMAL_LITERAL_REPRESENTATION,
495 mem_forget::MEM_FORGET,
496 methods::CLONE_ON_REF_PTR,
497 methods::OPTION_UNWRAP_USED,
498 methods::RESULT_UNWRAP_USED,
499 methods::WRONG_PUB_SELF_CONVENTION,
500 misc::FLOAT_CMP_CONST,
501 missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
502 missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
503 panic_unimplemented::UNIMPLEMENTED,
504 shadow::SHADOW_REUSE,
511 reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
512 attrs::INLINE_ALWAYS,
513 copies::MATCH_SAME_ARMS,
514 copy_iterator::COPY_ITERATOR,
515 default_trait_access::DEFAULT_TRAIT_ACCESS,
516 derive::EXPL_IMPL_CLONE_ON_COPY,
518 empty_enum::EMPTY_ENUM,
519 enum_glob_use::ENUM_GLOB_USE,
520 enum_variants::PUB_ENUM_VARIANT_NAMES,
521 enum_variants::STUTTER,
522 if_not_else::IF_NOT_ELSE,
523 infinite_iter::MAYBE_INFINITE_ITER,
524 items_after_statements::ITEMS_AFTER_STATEMENTS,
525 literal_representation::LARGE_DIGIT_GROUPS,
526 loops::EXPLICIT_INTO_ITER_LOOP,
527 loops::EXPLICIT_ITER_LOOP,
528 matches::SINGLE_MATCH_ELSE,
530 methods::MAP_FLATTEN,
531 methods::OPTION_MAP_UNWRAP_OR,
532 methods::OPTION_MAP_UNWRAP_OR_ELSE,
533 methods::RESULT_MAP_UNWRAP_OR_ELSE,
534 misc::USED_UNDERSCORE_BINDING,
535 misc_early::UNSEPARATED_LITERAL_SUFFIX,
537 needless_continue::NEEDLESS_CONTINUE,
538 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
539 non_expressive_names::SIMILAR_NAMES,
540 replace_consts::REPLACE_CONSTS,
541 shadow::SHADOW_UNRELATED,
542 strings::STRING_ADD_ASSIGN,
543 types::CAST_POSSIBLE_TRUNCATION,
544 types::CAST_POSSIBLE_WRAP,
545 types::CAST_PRECISION_LOSS,
546 types::CAST_SIGN_LOSS,
547 types::INVALID_UPCAST_COMPARISONS,
549 unicode::NON_ASCII_LITERAL,
550 unicode::UNICODE_NOT_NFC,
554 reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
555 utils::internal_lints::CLIPPY_LINTS_INTERNAL,
556 utils::internal_lints::COMPILER_LINT_FUNCTIONS,
557 utils::internal_lints::DEFAULT_HASH_TYPES,
558 utils::internal_lints::LINT_WITHOUT_LINT_PASS,
561 reg.register_lint_group("clippy::all", Some("clippy"), vec![
562 approx_const::APPROX_CONSTANT,
563 assign_ops::ASSIGN_OP_PATTERN,
564 assign_ops::MISREFACTORED_ASSIGN_OP,
565 attrs::DEPRECATED_CFG_ATTR,
566 attrs::DEPRECATED_SEMVER,
567 attrs::UNKNOWN_CLIPPY_LINTS,
568 attrs::USELESS_ATTRIBUTE,
569 bit_mask::BAD_BIT_MASK,
570 bit_mask::INEFFECTIVE_BIT_MASK,
571 bit_mask::VERBOSE_BIT_MASK,
572 blacklisted_name::BLACKLISTED_NAME,
573 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
574 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
576 booleans::NONMINIMAL_BOOL,
577 bytecount::NAIVE_BYTECOUNT,
578 collapsible_if::COLLAPSIBLE_IF,
579 const_static_lifetime::CONST_STATIC_LIFETIME,
580 copies::IFS_SAME_COND,
581 copies::IF_SAME_THEN_ELSE,
582 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
583 derive::DERIVE_HASH_XOR_EQ,
584 double_comparison::DOUBLE_COMPARISONS,
585 double_parens::DOUBLE_PARENS,
586 drop_forget_ref::DROP_COPY,
587 drop_forget_ref::DROP_REF,
588 drop_forget_ref::FORGET_COPY,
589 drop_forget_ref::FORGET_REF,
590 duration_subsec::DURATION_SUBSEC,
592 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
593 enum_variants::ENUM_VARIANT_NAMES,
594 enum_variants::MODULE_INCEPTION,
597 erasing_op::ERASING_OP,
599 eta_reduction::REDUNDANT_CLOSURE,
600 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
601 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
602 excessive_precision::EXCESSIVE_PRECISION,
603 explicit_write::EXPLICIT_WRITE,
604 format::USELESS_FORMAT,
605 formatting::POSSIBLE_MISSING_COMMA,
606 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
607 formatting::SUSPICIOUS_ELSE_FORMATTING,
608 functions::NOT_UNSAFE_PTR_ARG_DEREF,
609 functions::TOO_MANY_ARGUMENTS,
610 identity_conversion::IDENTITY_CONVERSION,
611 identity_op::IDENTITY_OP,
612 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
613 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
614 infinite_iter::INFINITE_ITER,
615 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
616 int_plus_one::INT_PLUS_ONE,
617 invalid_ref::INVALID_REF,
618 large_enum_variant::LARGE_ENUM_VARIANT,
619 len_zero::LEN_WITHOUT_IS_EMPTY,
621 let_if_seq::USELESS_LET_IF_SEQ,
622 lifetimes::EXTRA_UNUSED_LIFETIMES,
623 lifetimes::NEEDLESS_LIFETIMES,
624 literal_representation::INCONSISTENT_DIGIT_GROUPING,
625 literal_representation::MISTYPED_LITERAL_SUFFIXES,
626 literal_representation::UNREADABLE_LITERAL,
628 loops::EXPLICIT_COUNTER_LOOP,
630 loops::FOR_LOOP_OVER_OPTION,
631 loops::FOR_LOOP_OVER_RESULT,
632 loops::ITER_NEXT_LOOP,
633 loops::MANUAL_MEMCPY,
634 loops::MUT_RANGE_BOUND,
635 loops::NEEDLESS_COLLECT,
636 loops::NEEDLESS_RANGE_LOOP,
638 loops::REVERSE_RANGE_LOOP,
639 loops::UNUSED_COLLECT,
640 loops::WHILE_IMMUTABLE_CONDITION,
641 loops::WHILE_LET_LOOP,
642 loops::WHILE_LET_ON_ITERATOR,
643 map_clone::MAP_CLONE,
644 map_unit_fn::OPTION_MAP_UNIT_FN,
645 map_unit_fn::RESULT_MAP_UNIT_FN,
646 matches::MATCH_AS_REF,
648 matches::MATCH_OVERLAPPING_ARM,
649 matches::MATCH_REF_PATS,
650 matches::MATCH_WILD_ERR_ARM,
651 matches::SINGLE_MATCH,
652 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
653 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
654 methods::CHARS_LAST_CMP,
655 methods::CHARS_NEXT_CMP,
656 methods::CLONE_DOUBLE_REF,
657 methods::CLONE_ON_COPY,
658 methods::EXPECT_FUN_CALL,
659 methods::FILTER_NEXT,
661 methods::INTO_ITER_ON_ARRAY,
662 methods::INTO_ITER_ON_REF,
663 methods::ITER_CLONED_COLLECT,
665 methods::ITER_SKIP_NEXT,
666 methods::NEW_RET_NO_SELF,
668 methods::OPTION_MAP_OR_NONE,
669 methods::OR_FUN_CALL,
670 methods::SEARCH_IS_SOME,
671 methods::SHOULD_IMPLEMENT_TRAIT,
672 methods::SINGLE_CHAR_PATTERN,
673 methods::STRING_EXTEND_CHARS,
674 methods::TEMPORARY_CSTRING_AS_PTR,
675 methods::UNNECESSARY_FILTER_MAP,
676 methods::UNNECESSARY_FOLD,
677 methods::USELESS_ASREF,
678 methods::WRONG_SELF_CONVENTION,
684 misc::REDUNDANT_PATTERN,
685 misc::SHORT_CIRCUIT_STATEMENT,
686 misc::TOPLEVEL_REF_ARG,
688 misc_early::BUILTIN_TYPE_SHADOW,
689 misc_early::DOUBLE_NEG,
690 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
691 misc_early::MIXED_CASE_HEX_LITERALS,
692 misc_early::REDUNDANT_CLOSURE_CALL,
693 misc_early::UNNEEDED_FIELD_PATTERN,
694 misc_early::ZERO_PREFIXED_LITERAL,
695 mut_reference::UNNECESSARY_MUT_PASSED,
696 mutex_atomic::MUTEX_ATOMIC,
697 needless_bool::BOOL_COMPARISON,
698 needless_bool::NEEDLESS_BOOL,
699 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
700 needless_update::NEEDLESS_UPDATE,
701 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
702 neg_multiply::NEG_MULTIPLY,
703 new_without_default::NEW_WITHOUT_DEFAULT,
704 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
705 no_effect::NO_EFFECT,
706 no_effect::UNNECESSARY_OPERATION,
707 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
708 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
709 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
710 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
711 ok_if_let::IF_LET_SOME_RESULT,
712 open_options::NONSENSICAL_OPEN_OPTIONS,
713 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
714 panic_unimplemented::PANIC_PARAMS,
715 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
716 precedence::PRECEDENCE,
720 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
721 question_mark::QUESTION_MARK,
722 ranges::ITERATOR_STEP_BY_ZERO,
723 ranges::RANGE_MINUS_ONE,
724 ranges::RANGE_PLUS_ONE,
725 ranges::RANGE_ZIP_WITH_LEN,
726 redundant_field_names::REDUNDANT_FIELD_NAMES,
727 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
728 reference::DEREF_ADDROF,
729 reference::REF_IN_DEREF,
730 regex::INVALID_REGEX,
732 regex::TRIVIAL_REGEX,
733 returns::LET_AND_RETURN,
734 returns::NEEDLESS_RETURN,
735 returns::UNUSED_UNIT,
736 serde_api::SERDE_API_MISUSE,
737 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
738 strings::STRING_LIT_AS_BYTES,
739 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
740 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
741 swap::ALMOST_SWAPPED,
743 temporary_assignment::TEMPORARY_ASSIGNMENT,
744 transmute::CROSSPOINTER_TRANSMUTE,
745 transmute::TRANSMUTE_BYTES_TO_STR,
746 transmute::TRANSMUTE_INT_TO_BOOL,
747 transmute::TRANSMUTE_INT_TO_CHAR,
748 transmute::TRANSMUTE_INT_TO_FLOAT,
749 transmute::TRANSMUTE_PTR_TO_PTR,
750 transmute::TRANSMUTE_PTR_TO_REF,
751 transmute::USELESS_TRANSMUTE,
752 transmute::WRONG_TRANSMUTE,
753 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
754 types::ABSURD_EXTREME_COMPARISONS,
757 types::CAST_LOSSLESS,
758 types::CAST_PTR_ALIGNMENT,
759 types::CHAR_LIT_AS_U8,
760 types::FN_TO_NUMERIC_CAST,
761 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
762 types::IMPLICIT_HASHER,
763 types::LET_UNIT_VALUE,
764 types::OPTION_OPTION,
765 types::TYPE_COMPLEXITY,
768 types::UNNECESSARY_CAST,
770 unicode::ZERO_WIDTH_SPACE,
771 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
772 unused_io_amount::UNUSED_IO_AMOUNT,
773 unused_label::UNUSED_LABEL,
775 write::PRINTLN_EMPTY_STRING,
776 write::PRINT_LITERAL,
777 write::PRINT_WITH_NEWLINE,
778 write::WRITELN_EMPTY_STRING,
779 write::WRITE_LITERAL,
780 write::WRITE_WITH_NEWLINE,
781 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
784 reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
785 assign_ops::ASSIGN_OP_PATTERN,
786 attrs::UNKNOWN_CLIPPY_LINTS,
787 bit_mask::VERBOSE_BIT_MASK,
788 blacklisted_name::BLACKLISTED_NAME,
789 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
790 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
791 collapsible_if::COLLAPSIBLE_IF,
792 const_static_lifetime::CONST_STATIC_LIFETIME,
793 enum_variants::ENUM_VARIANT_NAMES,
794 enum_variants::MODULE_INCEPTION,
796 eta_reduction::REDUNDANT_CLOSURE,
797 excessive_precision::EXCESSIVE_PRECISION,
798 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
799 formatting::SUSPICIOUS_ELSE_FORMATTING,
800 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
801 len_zero::LEN_WITHOUT_IS_EMPTY,
803 let_if_seq::USELESS_LET_IF_SEQ,
804 literal_representation::INCONSISTENT_DIGIT_GROUPING,
805 literal_representation::UNREADABLE_LITERAL,
808 loops::NEEDLESS_RANGE_LOOP,
809 loops::WHILE_LET_ON_ITERATOR,
810 map_clone::MAP_CLONE,
812 matches::MATCH_OVERLAPPING_ARM,
813 matches::MATCH_REF_PATS,
814 matches::MATCH_WILD_ERR_ARM,
815 matches::SINGLE_MATCH,
816 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
817 methods::CHARS_LAST_CMP,
819 methods::INTO_ITER_ON_REF,
820 methods::ITER_CLONED_COLLECT,
821 methods::ITER_SKIP_NEXT,
822 methods::NEW_RET_NO_SELF,
824 methods::OPTION_MAP_OR_NONE,
825 methods::SHOULD_IMPLEMENT_TRAIT,
826 methods::STRING_EXTEND_CHARS,
827 methods::UNNECESSARY_FOLD,
828 methods::WRONG_SELF_CONVENTION,
829 misc::REDUNDANT_PATTERN,
830 misc::TOPLEVEL_REF_ARG,
832 misc_early::BUILTIN_TYPE_SHADOW,
833 misc_early::DOUBLE_NEG,
834 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
835 misc_early::MIXED_CASE_HEX_LITERALS,
836 misc_early::UNNEEDED_FIELD_PATTERN,
837 mut_reference::UNNECESSARY_MUT_PASSED,
838 neg_multiply::NEG_MULTIPLY,
839 new_without_default::NEW_WITHOUT_DEFAULT,
840 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
841 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
842 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
843 ok_if_let::IF_LET_SOME_RESULT,
844 panic_unimplemented::PANIC_PARAMS,
847 question_mark::QUESTION_MARK,
848 redundant_field_names::REDUNDANT_FIELD_NAMES,
849 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
851 regex::TRIVIAL_REGEX,
852 returns::LET_AND_RETURN,
853 returns::NEEDLESS_RETURN,
854 returns::UNUSED_UNIT,
855 strings::STRING_LIT_AS_BYTES,
856 types::FN_TO_NUMERIC_CAST,
857 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
858 types::IMPLICIT_HASHER,
859 types::LET_UNIT_VALUE,
860 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
861 write::PRINTLN_EMPTY_STRING,
862 write::PRINT_LITERAL,
863 write::PRINT_WITH_NEWLINE,
864 write::WRITELN_EMPTY_STRING,
865 write::WRITE_LITERAL,
866 write::WRITE_WITH_NEWLINE,
869 reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
870 assign_ops::MISREFACTORED_ASSIGN_OP,
871 attrs::DEPRECATED_CFG_ATTR,
872 booleans::NONMINIMAL_BOOL,
873 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
874 double_comparison::DOUBLE_COMPARISONS,
875 double_parens::DOUBLE_PARENS,
876 duration_subsec::DURATION_SUBSEC,
877 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
878 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
879 explicit_write::EXPLICIT_WRITE,
880 format::USELESS_FORMAT,
881 functions::TOO_MANY_ARGUMENTS,
882 identity_conversion::IDENTITY_CONVERSION,
883 identity_op::IDENTITY_OP,
884 int_plus_one::INT_PLUS_ONE,
885 lifetimes::EXTRA_UNUSED_LIFETIMES,
886 lifetimes::NEEDLESS_LIFETIMES,
887 loops::EXPLICIT_COUNTER_LOOP,
888 loops::MUT_RANGE_BOUND,
889 loops::WHILE_LET_LOOP,
890 map_unit_fn::OPTION_MAP_UNIT_FN,
891 map_unit_fn::RESULT_MAP_UNIT_FN,
892 matches::MATCH_AS_REF,
893 methods::CHARS_NEXT_CMP,
894 methods::CLONE_ON_COPY,
895 methods::FILTER_NEXT,
896 methods::SEARCH_IS_SOME,
897 methods::UNNECESSARY_FILTER_MAP,
898 methods::USELESS_ASREF,
899 misc::SHORT_CIRCUIT_STATEMENT,
900 misc_early::REDUNDANT_CLOSURE_CALL,
901 misc_early::ZERO_PREFIXED_LITERAL,
902 needless_bool::BOOL_COMPARISON,
903 needless_bool::NEEDLESS_BOOL,
904 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
905 needless_update::NEEDLESS_UPDATE,
906 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
907 no_effect::NO_EFFECT,
908 no_effect::UNNECESSARY_OPERATION,
909 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
910 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
911 precedence::PRECEDENCE,
912 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
913 ranges::RANGE_MINUS_ONE,
914 ranges::RANGE_PLUS_ONE,
915 ranges::RANGE_ZIP_WITH_LEN,
916 reference::DEREF_ADDROF,
917 reference::REF_IN_DEREF,
919 temporary_assignment::TEMPORARY_ASSIGNMENT,
920 transmute::CROSSPOINTER_TRANSMUTE,
921 transmute::TRANSMUTE_BYTES_TO_STR,
922 transmute::TRANSMUTE_INT_TO_BOOL,
923 transmute::TRANSMUTE_INT_TO_CHAR,
924 transmute::TRANSMUTE_INT_TO_FLOAT,
925 transmute::TRANSMUTE_PTR_TO_PTR,
926 transmute::TRANSMUTE_PTR_TO_REF,
927 transmute::USELESS_TRANSMUTE,
929 types::CAST_LOSSLESS,
930 types::CHAR_LIT_AS_U8,
931 types::OPTION_OPTION,
932 types::TYPE_COMPLEXITY,
934 types::UNNECESSARY_CAST,
936 unused_label::UNUSED_LABEL,
937 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
940 reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
941 approx_const::APPROX_CONSTANT,
942 attrs::DEPRECATED_SEMVER,
943 attrs::USELESS_ATTRIBUTE,
944 bit_mask::BAD_BIT_MASK,
945 bit_mask::INEFFECTIVE_BIT_MASK,
947 copies::IFS_SAME_COND,
948 copies::IF_SAME_THEN_ELSE,
949 derive::DERIVE_HASH_XOR_EQ,
950 drop_forget_ref::DROP_COPY,
951 drop_forget_ref::DROP_REF,
952 drop_forget_ref::FORGET_COPY,
953 drop_forget_ref::FORGET_REF,
954 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
956 erasing_op::ERASING_OP,
957 formatting::POSSIBLE_MISSING_COMMA,
958 functions::NOT_UNSAFE_PTR_ARG_DEREF,
959 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
960 infinite_iter::INFINITE_ITER,
961 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
962 invalid_ref::INVALID_REF,
963 literal_representation::MISTYPED_LITERAL_SUFFIXES,
964 loops::FOR_LOOP_OVER_OPTION,
965 loops::FOR_LOOP_OVER_RESULT,
966 loops::ITER_NEXT_LOOP,
968 loops::REVERSE_RANGE_LOOP,
969 loops::WHILE_IMMUTABLE_CONDITION,
970 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
971 methods::CLONE_DOUBLE_REF,
972 methods::INTO_ITER_ON_ARRAY,
973 methods::TEMPORARY_CSTRING_AS_PTR,
978 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
979 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
980 open_options::NONSENSICAL_OPEN_OPTIONS,
982 ranges::ITERATOR_STEP_BY_ZERO,
983 regex::INVALID_REGEX,
984 serde_api::SERDE_API_MISUSE,
985 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
986 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
987 swap::ALMOST_SWAPPED,
988 transmute::WRONG_TRANSMUTE,
989 types::ABSURD_EXTREME_COMPARISONS,
990 types::CAST_PTR_ALIGNMENT,
992 unicode::ZERO_WIDTH_SPACE,
993 unused_io_amount::UNUSED_IO_AMOUNT,
996 reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
997 bytecount::NAIVE_BYTECOUNT,
1000 large_enum_variant::LARGE_ENUM_VARIANT,
1001 loops::MANUAL_MEMCPY,
1002 loops::NEEDLESS_COLLECT,
1003 loops::UNUSED_COLLECT,
1004 methods::EXPECT_FUN_CALL,
1006 methods::OR_FUN_CALL,
1007 methods::SINGLE_CHAR_PATTERN,
1009 mutex_atomic::MUTEX_ATOMIC,
1010 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
1011 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
1016 reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
1017 cargo_common_metadata::CARGO_COMMON_METADATA,
1018 multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
1019 wildcard_dependencies::WILDCARD_DEPENDENCIES,
1022 reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
1023 attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
1024 fallible_impl_from::FALLIBLE_IMPL_FROM,
1025 mutex_atomic::MUTEX_INTEGER,
1026 needless_borrow::NEEDLESS_BORROW,
1027 redundant_clone::REDUNDANT_CLONE,
1028 unwrap::PANICKING_UNWRAP,
1029 unwrap::UNNECESSARY_UNWRAP,
1033 // only exists to let the dogfood integration test works.
1034 // Don't run clippy as an executable directly
1037 panic!("Please use the cargo-clippy executable");