1 // error-pattern:cargo-clippy
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)]
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)]
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)]
35 #[allow(unused_extern_crates)]
36 extern crate syntax_pos;
40 // Currently, categories "style", "correctness", "complexity" and "perf" are enabled by default,
41 // as said in the README.md of this repository. If this changes, please update README.md.
43 macro_rules! declare_clippy_lint {
44 { pub $name:tt, style, $description:tt } => {
45 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
47 { pub $name:tt, correctness, $description:tt } => {
48 declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true }
50 { pub $name:tt, complexity, $description:tt } => {
51 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
53 { pub $name:tt, perf, $description:tt } => {
54 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
56 { pub $name:tt, pedantic, $description:tt } => {
57 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
59 { pub $name:tt, restriction, $description:tt } => {
60 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
62 { pub $name:tt, cargo, $description:tt } => {
63 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
65 { pub $name:tt, nursery, $description:tt } => {
66 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
68 { pub $name:tt, internal, $description:tt } => {
69 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
71 { pub $name:tt, internal_warn, $description:tt } => {
72 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
80 // begin lints modules, do not remove this comment, it’s used in `update_lints`
83 pub mod assertions_on_constants;
87 pub mod blacklisted_name;
88 pub mod block_in_if_condition;
91 pub mod cargo_common_metadata;
92 pub mod collapsible_if;
93 pub mod const_static_lifetime;
95 pub mod copy_iterator;
96 pub mod cyclomatic_complexity;
98 pub mod default_trait_access;
101 pub mod double_comparison;
102 pub mod double_parens;
103 pub mod drop_forget_ref;
104 pub mod duration_subsec;
105 pub mod else_if_without_else;
109 pub mod enum_glob_use;
110 pub mod enum_variants;
114 pub mod eta_reduction;
115 pub mod eval_order_dependence;
116 pub mod excessive_precision;
117 pub mod explicit_write;
118 pub mod fallible_impl_from;
122 pub mod identity_conversion;
125 pub mod implicit_return;
126 pub mod indexing_slicing;
127 pub mod infallible_destructuring_match;
128 pub mod infinite_iter;
129 pub mod inherent_impl;
130 pub mod inline_fn_without_body;
131 pub mod int_plus_one;
133 pub mod items_after_statements;
134 pub mod large_enum_variant;
138 pub mod literal_representation;
143 pub mod mem_discriminant;
150 pub mod missing_const_for_fn;
152 pub mod missing_inline;
153 pub mod multiple_crate_versions;
155 pub mod mut_reference;
156 pub mod mutex_atomic;
157 pub mod needless_bool;
158 pub mod needless_borrow;
159 pub mod needless_borrowed_ref;
160 pub mod needless_continue;
161 pub mod needless_pass_by_value;
162 pub mod needless_update;
163 pub mod neg_cmp_op_on_partial_ord;
164 pub mod neg_multiply;
165 pub mod new_without_default;
167 pub mod non_copy_const;
168 pub mod non_expressive_names;
170 pub mod open_options;
171 pub mod overflow_check_conditional;
172 pub mod panic_unimplemented;
173 pub mod partialeq_ne_impl;
176 pub mod ptr_offset_with_cast;
177 pub mod question_mark;
179 pub mod redundant_clone;
180 pub mod redundant_field_names;
181 pub mod redundant_pattern_matching;
184 pub mod replace_consts;
188 pub mod slow_vector_initialization;
190 pub mod suspicious_trait_impl;
192 pub mod temporary_assignment;
194 pub mod trivially_copy_pass_by_ref;
197 pub mod unsafe_removed_from_name;
198 pub mod unused_io_amount;
199 pub mod unused_label;
203 pub mod wildcard_dependencies;
205 pub mod zero_div_zero;
206 // end lints modules, do not remove this comment, it’s used in `update_lints`
208 pub use crate::utils::conf::Conf;
211 crate use syntax::ast::{Name, NodeId};
214 pub fn register_pre_expansion_lints(
215 session: &rustc::session::Session,
216 store: &mut rustc::lint::LintStore,
219 store.register_pre_expansion_pass(Some(session), true, false, box write::Pass);
220 store.register_pre_expansion_pass(
224 box redundant_field_names::RedundantFieldNames,
226 store.register_pre_expansion_pass(
230 box non_expressive_names::NonExpressiveNames {
231 single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
234 store.register_pre_expansion_pass(Some(session), true, false, box attrs::CfgAttrPass);
235 store.register_pre_expansion_pass(Some(session), true, false, box dbg_macro::Pass);
238 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
239 match utils::conf::file_from_args(reg.args()) {
241 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
242 // do not require the file to exist
243 let file_name = if let Some(file_name) = file_name {
246 match utils::conf::lookup_conf_file() {
250 .struct_err(&format!("error finding Clippy's configuration file: {}", error))
257 let file_name = file_name.map(|file_name| {
258 if file_name.is_relative() {
260 .local_crate_source_file
262 .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
270 let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
272 // all conf errors are non-fatal, we just use the default conf in case of error
273 for error in errors {
275 .struct_err(&format!(
276 "error reading Clippy's configuration file `{}`: {}",
277 file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""),
285 Err((err, span)) => {
287 .struct_span_err(span, err)
288 .span_note(span, "Clippy will use default configuration")
290 toml::from_str("").expect("we never error on empty config files")
295 #[allow(clippy::too_many_lines)]
297 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
298 let mut store = reg.sess.lint_store.borrow_mut();
299 // begin deprecated lints, do not remove this comment, it’s used in `update_lints`
300 store.register_removed(
302 "`assert!()` will be more flexible with RFC 2011",
304 store.register_removed(
306 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
308 store.register_removed(
309 "range_step_by_zero",
310 "`iterator.step_by(0)` panics nowadays",
312 store.register_removed(
314 "`Vec::as_slice` has been stabilized in 1.7",
316 store.register_removed(
317 "unstable_as_mut_slice",
318 "`Vec::as_mut_slice` has been stabilized in 1.7",
320 store.register_removed(
322 "using `str::to_string` is common even today and specialization will likely happen soon",
324 store.register_removed(
326 "using `string::to_string` is common even today and specialization will likely happen soon",
328 store.register_removed(
329 "misaligned_transmute",
330 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
332 store.register_removed(
334 "using compound assignment operators (e.g. `+=`) is harmless",
336 store.register_removed(
337 "if_let_redundant_pattern_matching",
338 "this lint has been changed to redundant_pattern_matching",
340 store.register_removed(
341 "unsafe_vector_initialization",
342 "the replacement suggested by this lint had substantially different behavior",
344 // end deprecated lints, do not remove this comment, it’s used in `update_lints`
346 reg.register_late_lint_pass(box serde_api::Serde);
347 reg.register_early_lint_pass(box utils::internal_lints::Clippy);
348 reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
349 reg.register_early_lint_pass(box utils::internal_lints::DefaultHashTypes::default());
350 reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
351 reg.register_late_lint_pass(box utils::inspector::Pass);
352 reg.register_late_lint_pass(box utils::author::Pass);
353 reg.register_late_lint_pass(box types::TypePass);
354 reg.register_late_lint_pass(box booleans::NonminimalBool);
355 reg.register_late_lint_pass(box eq_op::EqOp);
356 reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
357 reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
358 reg.register_late_lint_pass(box enum_clike::UnportableVariant);
359 reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
360 reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
361 reg.register_late_lint_pass(box ptr::PointerPass);
362 reg.register_late_lint_pass(box needless_bool::NeedlessBool);
363 reg.register_late_lint_pass(box needless_bool::BoolComparison);
364 reg.register_late_lint_pass(box approx_const::Pass);
365 reg.register_late_lint_pass(box misc::Pass);
366 reg.register_early_lint_pass(box precedence::Precedence);
367 reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
368 reg.register_late_lint_pass(box eta_reduction::EtaPass);
369 reg.register_late_lint_pass(box identity_op::IdentityOp);
370 reg.register_late_lint_pass(box erasing_op::ErasingOp);
371 reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
372 reg.register_late_lint_pass(box mut_mut::MutMut);
373 reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
374 reg.register_late_lint_pass(box len_zero::LenZero);
375 reg.register_late_lint_pass(box attrs::AttrPass);
376 reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
377 reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
378 reg.register_late_lint_pass(box unicode::Unicode);
379 reg.register_late_lint_pass(box strings::StringAdd);
380 reg.register_early_lint_pass(box returns::ReturnPass);
381 reg.register_late_lint_pass(box implicit_return::Pass);
382 reg.register_late_lint_pass(box methods::Pass);
383 reg.register_late_lint_pass(box map_clone::Pass);
384 reg.register_late_lint_pass(box shadow::Pass);
385 reg.register_late_lint_pass(box types::LetPass);
386 reg.register_late_lint_pass(box types::UnitCmp);
387 reg.register_late_lint_pass(box loops::Pass);
388 reg.register_late_lint_pass(box lifetimes::LifetimePass);
389 reg.register_late_lint_pass(box entry::HashMapLint);
390 reg.register_late_lint_pass(box ranges::Pass);
391 reg.register_late_lint_pass(box types::CastPass);
392 reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
393 reg.register_late_lint_pass(box matches::MatchPass);
394 reg.register_late_lint_pass(box minmax::MinMaxPass);
395 reg.register_late_lint_pass(box open_options::NonSensical);
396 reg.register_late_lint_pass(box zero_div_zero::Pass);
397 reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
398 reg.register_late_lint_pass(box needless_update::Pass);
399 reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow::default());
400 reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
401 reg.register_late_lint_pass(box no_effect::Pass);
402 reg.register_late_lint_pass(box temporary_assignment::Pass);
403 reg.register_late_lint_pass(box transmute::Transmute);
404 reg.register_late_lint_pass(
405 box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
407 reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
408 reg.register_early_lint_pass(box misc_early::MiscEarly);
409 reg.register_late_lint_pass(box panic_unimplemented::Pass);
410 reg.register_late_lint_pass(box strings::StringLitAsBytes);
411 reg.register_late_lint_pass(box derive::Derive);
412 reg.register_late_lint_pass(box types::CharLitAsU8);
413 reg.register_late_lint_pass(box vec::Pass);
414 reg.register_late_lint_pass(box drop_forget_ref::Pass);
415 reg.register_late_lint_pass(box empty_enum::EmptyEnum);
416 reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
417 reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
418 reg.register_late_lint_pass(box regex::Pass::default());
419 reg.register_late_lint_pass(box copies::CopyAndPaste);
420 reg.register_late_lint_pass(box copy_iterator::CopyIterator);
421 reg.register_late_lint_pass(box format::Pass);
422 reg.register_early_lint_pass(box formatting::Formatting);
423 reg.register_late_lint_pass(box swap::Swap);
424 reg.register_early_lint_pass(box if_not_else::IfNotElse);
425 reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
426 reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
427 reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
428 reg.register_late_lint_pass(box unused_label::UnusedLabel);
429 reg.register_late_lint_pass(box new_without_default::NewWithoutDefault::default());
430 reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(
431 conf.blacklisted_names.iter().cloned().collect()
433 reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold, conf.too_many_lines_threshold));
434 reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents.iter().cloned().collect()));
435 reg.register_late_lint_pass(box neg_multiply::NegMultiply);
436 reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
437 reg.register_late_lint_pass(box mem_discriminant::MemDiscriminant);
438 reg.register_late_lint_pass(box mem_forget::MemForget);
439 reg.register_late_lint_pass(box mem_replace::MemReplace);
440 reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
441 reg.register_late_lint_pass(box assign_ops::AssignOps);
442 reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
443 reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
444 reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
445 reg.register_late_lint_pass(box missing_inline::MissingInline);
446 reg.register_late_lint_pass(box ok_if_let::Pass);
447 reg.register_late_lint_pass(box redundant_pattern_matching::Pass);
448 reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
449 reg.register_early_lint_pass(box reference::Pass);
450 reg.register_early_lint_pass(box reference::DerefPass);
451 reg.register_early_lint_pass(box double_parens::DoubleParens);
452 reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
453 reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
454 reg.register_late_lint_pass(box explicit_write::Pass);
455 reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
456 reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
457 conf.trivial_copy_size_limit,
460 reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
461 reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
462 conf.literal_representation_threshold
464 reg.register_late_lint_pass(box use_self::UseSelf);
465 reg.register_late_lint_pass(box bytecount::ByteCount);
466 reg.register_late_lint_pass(box infinite_iter::Pass);
467 reg.register_late_lint_pass(box inline_fn_without_body::Pass);
468 reg.register_late_lint_pass(box invalid_ref::InvalidRef);
469 reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
470 reg.register_late_lint_pass(box types::ImplicitHasher);
471 reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
472 reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
473 reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
474 reg.register_late_lint_pass(box types::UnitArg);
475 reg.register_late_lint_pass(box double_comparison::Pass);
476 reg.register_late_lint_pass(box question_mark::Pass);
477 reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
478 reg.register_early_lint_pass(box cargo_common_metadata::Pass);
479 reg.register_early_lint_pass(box multiple_crate_versions::Pass);
480 reg.register_early_lint_pass(box wildcard_dependencies::Pass);
481 reg.register_late_lint_pass(box map_unit_fn::Pass);
482 reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
483 reg.register_late_lint_pass(box inherent_impl::Pass::default());
484 reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
485 reg.register_late_lint_pass(box unwrap::Pass);
486 reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
487 reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
488 reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
489 reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
490 reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
491 reg.register_late_lint_pass(box redundant_clone::RedundantClone);
492 reg.register_late_lint_pass(box slow_vector_initialization::Pass);
493 reg.register_late_lint_pass(box types::RefToMut);
494 reg.register_late_lint_pass(box assertions_on_constants::AssertionsOnConstants);
495 reg.register_late_lint_pass(box missing_const_for_fn::MissingConstForFn);
497 reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
498 arithmetic::FLOAT_ARITHMETIC,
499 arithmetic::INTEGER_ARITHMETIC,
500 dbg_macro::DBG_MACRO,
501 else_if_without_else::ELSE_IF_WITHOUT_ELSE,
502 implicit_return::IMPLICIT_RETURN,
503 indexing_slicing::INDEXING_SLICING,
504 inherent_impl::MULTIPLE_INHERENT_IMPL,
505 literal_representation::DECIMAL_LITERAL_REPRESENTATION,
506 matches::WILDCARD_ENUM_MATCH_ARM,
507 mem_forget::MEM_FORGET,
508 methods::CLONE_ON_REF_PTR,
509 methods::OPTION_UNWRAP_USED,
510 methods::RESULT_UNWRAP_USED,
511 methods::WRONG_PUB_SELF_CONVENTION,
512 misc::FLOAT_CMP_CONST,
513 missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
514 missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
515 panic_unimplemented::UNIMPLEMENTED,
516 shadow::SHADOW_REUSE,
523 reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
524 attrs::INLINE_ALWAYS,
525 copies::MATCH_SAME_ARMS,
526 copy_iterator::COPY_ITERATOR,
527 default_trait_access::DEFAULT_TRAIT_ACCESS,
528 derive::EXPL_IMPL_CLONE_ON_COPY,
530 empty_enum::EMPTY_ENUM,
531 enum_glob_use::ENUM_GLOB_USE,
532 enum_variants::MODULE_NAME_REPETITIONS,
533 enum_variants::PUB_ENUM_VARIANT_NAMES,
534 functions::TOO_MANY_LINES,
535 if_not_else::IF_NOT_ELSE,
536 infinite_iter::MAYBE_INFINITE_ITER,
537 items_after_statements::ITEMS_AFTER_STATEMENTS,
538 literal_representation::LARGE_DIGIT_GROUPS,
539 loops::EXPLICIT_INTO_ITER_LOOP,
540 loops::EXPLICIT_ITER_LOOP,
541 matches::SINGLE_MATCH_ELSE,
543 methods::MAP_FLATTEN,
544 methods::OPTION_MAP_UNWRAP_OR,
545 methods::OPTION_MAP_UNWRAP_OR_ELSE,
546 methods::RESULT_MAP_UNWRAP_OR_ELSE,
547 misc::USED_UNDERSCORE_BINDING,
548 misc_early::UNSEPARATED_LITERAL_SUFFIX,
550 needless_continue::NEEDLESS_CONTINUE,
551 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
552 non_expressive_names::SIMILAR_NAMES,
553 replace_consts::REPLACE_CONSTS,
554 shadow::SHADOW_UNRELATED,
555 strings::STRING_ADD_ASSIGN,
556 types::CAST_POSSIBLE_TRUNCATION,
557 types::CAST_POSSIBLE_WRAP,
558 types::CAST_PRECISION_LOSS,
559 types::CAST_SIGN_LOSS,
560 types::INVALID_UPCAST_COMPARISONS,
562 unicode::NON_ASCII_LITERAL,
563 unicode::UNICODE_NOT_NFC,
567 reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
568 utils::internal_lints::CLIPPY_LINTS_INTERNAL,
569 utils::internal_lints::COMPILER_LINT_FUNCTIONS,
570 utils::internal_lints::DEFAULT_HASH_TYPES,
571 utils::internal_lints::LINT_WITHOUT_LINT_PASS,
574 reg.register_lint_group("clippy::all", Some("clippy"), vec![
575 approx_const::APPROX_CONSTANT,
576 assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
577 assign_ops::ASSIGN_OP_PATTERN,
578 assign_ops::MISREFACTORED_ASSIGN_OP,
579 attrs::DEPRECATED_CFG_ATTR,
580 attrs::DEPRECATED_SEMVER,
581 attrs::UNKNOWN_CLIPPY_LINTS,
582 attrs::USELESS_ATTRIBUTE,
583 bit_mask::BAD_BIT_MASK,
584 bit_mask::INEFFECTIVE_BIT_MASK,
585 bit_mask::VERBOSE_BIT_MASK,
586 blacklisted_name::BLACKLISTED_NAME,
587 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
588 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
590 booleans::NONMINIMAL_BOOL,
591 bytecount::NAIVE_BYTECOUNT,
592 collapsible_if::COLLAPSIBLE_IF,
593 const_static_lifetime::CONST_STATIC_LIFETIME,
594 copies::IFS_SAME_COND,
595 copies::IF_SAME_THEN_ELSE,
596 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
597 derive::DERIVE_HASH_XOR_EQ,
598 double_comparison::DOUBLE_COMPARISONS,
599 double_parens::DOUBLE_PARENS,
600 drop_forget_ref::DROP_COPY,
601 drop_forget_ref::DROP_REF,
602 drop_forget_ref::FORGET_COPY,
603 drop_forget_ref::FORGET_REF,
604 duration_subsec::DURATION_SUBSEC,
606 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
607 enum_variants::ENUM_VARIANT_NAMES,
608 enum_variants::MODULE_INCEPTION,
611 erasing_op::ERASING_OP,
613 eta_reduction::REDUNDANT_CLOSURE,
614 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
615 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
616 excessive_precision::EXCESSIVE_PRECISION,
617 explicit_write::EXPLICIT_WRITE,
618 format::USELESS_FORMAT,
619 formatting::POSSIBLE_MISSING_COMMA,
620 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
621 formatting::SUSPICIOUS_ELSE_FORMATTING,
622 functions::NOT_UNSAFE_PTR_ARG_DEREF,
623 functions::TOO_MANY_ARGUMENTS,
624 identity_conversion::IDENTITY_CONVERSION,
625 identity_op::IDENTITY_OP,
626 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
627 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
628 infinite_iter::INFINITE_ITER,
629 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
630 int_plus_one::INT_PLUS_ONE,
631 invalid_ref::INVALID_REF,
632 large_enum_variant::LARGE_ENUM_VARIANT,
633 len_zero::LEN_WITHOUT_IS_EMPTY,
635 let_if_seq::USELESS_LET_IF_SEQ,
636 lifetimes::EXTRA_UNUSED_LIFETIMES,
637 lifetimes::NEEDLESS_LIFETIMES,
638 literal_representation::INCONSISTENT_DIGIT_GROUPING,
639 literal_representation::MISTYPED_LITERAL_SUFFIXES,
640 literal_representation::UNREADABLE_LITERAL,
642 loops::EXPLICIT_COUNTER_LOOP,
644 loops::FOR_LOOP_OVER_OPTION,
645 loops::FOR_LOOP_OVER_RESULT,
646 loops::ITER_NEXT_LOOP,
647 loops::MANUAL_MEMCPY,
648 loops::MUT_RANGE_BOUND,
649 loops::NEEDLESS_COLLECT,
650 loops::NEEDLESS_RANGE_LOOP,
652 loops::REVERSE_RANGE_LOOP,
653 loops::UNUSED_COLLECT,
654 loops::WHILE_IMMUTABLE_CONDITION,
655 loops::WHILE_LET_LOOP,
656 loops::WHILE_LET_ON_ITERATOR,
657 map_clone::MAP_CLONE,
658 map_unit_fn::OPTION_MAP_UNIT_FN,
659 map_unit_fn::RESULT_MAP_UNIT_FN,
660 matches::MATCH_AS_REF,
662 matches::MATCH_OVERLAPPING_ARM,
663 matches::MATCH_REF_PATS,
664 matches::MATCH_WILD_ERR_ARM,
665 matches::SINGLE_MATCH,
666 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
667 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
668 methods::CHARS_LAST_CMP,
669 methods::CHARS_NEXT_CMP,
670 methods::CLONE_DOUBLE_REF,
671 methods::CLONE_ON_COPY,
672 methods::EXPECT_FUN_CALL,
673 methods::FILTER_NEXT,
675 methods::INTO_ITER_ON_ARRAY,
676 methods::INTO_ITER_ON_REF,
677 methods::ITER_CLONED_COLLECT,
679 methods::ITER_SKIP_NEXT,
680 methods::NEW_RET_NO_SELF,
682 methods::OPTION_MAP_OR_NONE,
683 methods::OR_FUN_CALL,
684 methods::SEARCH_IS_SOME,
685 methods::SHOULD_IMPLEMENT_TRAIT,
686 methods::SINGLE_CHAR_PATTERN,
687 methods::STRING_EXTEND_CHARS,
688 methods::TEMPORARY_CSTRING_AS_PTR,
689 methods::UNNECESSARY_FILTER_MAP,
690 methods::UNNECESSARY_FOLD,
691 methods::USELESS_ASREF,
692 methods::WRONG_SELF_CONVENTION,
698 misc::REDUNDANT_PATTERN,
699 misc::SHORT_CIRCUIT_STATEMENT,
700 misc::TOPLEVEL_REF_ARG,
702 misc_early::BUILTIN_TYPE_SHADOW,
703 misc_early::DOUBLE_NEG,
704 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
705 misc_early::MIXED_CASE_HEX_LITERALS,
706 misc_early::REDUNDANT_CLOSURE_CALL,
707 misc_early::UNNEEDED_FIELD_PATTERN,
708 misc_early::ZERO_PREFIXED_LITERAL,
709 mut_reference::UNNECESSARY_MUT_PASSED,
710 mutex_atomic::MUTEX_ATOMIC,
711 needless_bool::BOOL_COMPARISON,
712 needless_bool::NEEDLESS_BOOL,
713 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
714 needless_update::NEEDLESS_UPDATE,
715 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
716 neg_multiply::NEG_MULTIPLY,
717 new_without_default::NEW_WITHOUT_DEFAULT,
718 no_effect::NO_EFFECT,
719 no_effect::UNNECESSARY_OPERATION,
720 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
721 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
722 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
723 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
724 ok_if_let::IF_LET_SOME_RESULT,
725 open_options::NONSENSICAL_OPEN_OPTIONS,
726 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
727 panic_unimplemented::PANIC_PARAMS,
728 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
729 precedence::PRECEDENCE,
733 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
734 question_mark::QUESTION_MARK,
735 ranges::ITERATOR_STEP_BY_ZERO,
736 ranges::RANGE_MINUS_ONE,
737 ranges::RANGE_PLUS_ONE,
738 ranges::RANGE_ZIP_WITH_LEN,
739 redundant_field_names::REDUNDANT_FIELD_NAMES,
740 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
741 reference::DEREF_ADDROF,
742 reference::REF_IN_DEREF,
743 regex::INVALID_REGEX,
745 regex::TRIVIAL_REGEX,
746 returns::LET_AND_RETURN,
747 returns::NEEDLESS_RETURN,
748 returns::UNUSED_UNIT,
749 serde_api::SERDE_API_MISUSE,
750 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
751 strings::STRING_LIT_AS_BYTES,
752 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
753 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
754 swap::ALMOST_SWAPPED,
756 temporary_assignment::TEMPORARY_ASSIGNMENT,
757 transmute::CROSSPOINTER_TRANSMUTE,
758 transmute::TRANSMUTE_BYTES_TO_STR,
759 transmute::TRANSMUTE_INT_TO_BOOL,
760 transmute::TRANSMUTE_INT_TO_CHAR,
761 transmute::TRANSMUTE_INT_TO_FLOAT,
762 transmute::TRANSMUTE_PTR_TO_PTR,
763 transmute::TRANSMUTE_PTR_TO_REF,
764 transmute::USELESS_TRANSMUTE,
765 transmute::WRONG_TRANSMUTE,
766 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
767 types::ABSURD_EXTREME_COMPARISONS,
770 types::CAST_LOSSLESS,
771 types::CAST_PTR_ALIGNMENT,
772 types::CAST_REF_TO_MUT,
773 types::CHAR_LIT_AS_U8,
774 types::FN_TO_NUMERIC_CAST,
775 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
776 types::IMPLICIT_HASHER,
777 types::LET_UNIT_VALUE,
778 types::OPTION_OPTION,
779 types::TYPE_COMPLEXITY,
782 types::UNNECESSARY_CAST,
784 unicode::ZERO_WIDTH_SPACE,
785 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
786 unused_io_amount::UNUSED_IO_AMOUNT,
787 unused_label::UNUSED_LABEL,
789 write::PRINTLN_EMPTY_STRING,
790 write::PRINT_LITERAL,
791 write::PRINT_WITH_NEWLINE,
792 write::WRITELN_EMPTY_STRING,
793 write::WRITE_LITERAL,
794 write::WRITE_WITH_NEWLINE,
795 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
798 reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
799 assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
800 assign_ops::ASSIGN_OP_PATTERN,
801 attrs::UNKNOWN_CLIPPY_LINTS,
802 bit_mask::VERBOSE_BIT_MASK,
803 blacklisted_name::BLACKLISTED_NAME,
804 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
805 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
806 collapsible_if::COLLAPSIBLE_IF,
807 const_static_lifetime::CONST_STATIC_LIFETIME,
808 enum_variants::ENUM_VARIANT_NAMES,
809 enum_variants::MODULE_INCEPTION,
811 eta_reduction::REDUNDANT_CLOSURE,
812 excessive_precision::EXCESSIVE_PRECISION,
813 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
814 formatting::SUSPICIOUS_ELSE_FORMATTING,
815 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
816 len_zero::LEN_WITHOUT_IS_EMPTY,
818 let_if_seq::USELESS_LET_IF_SEQ,
819 literal_representation::INCONSISTENT_DIGIT_GROUPING,
820 literal_representation::UNREADABLE_LITERAL,
823 loops::NEEDLESS_RANGE_LOOP,
824 loops::WHILE_LET_ON_ITERATOR,
825 map_clone::MAP_CLONE,
827 matches::MATCH_OVERLAPPING_ARM,
828 matches::MATCH_REF_PATS,
829 matches::MATCH_WILD_ERR_ARM,
830 matches::SINGLE_MATCH,
831 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
832 methods::CHARS_LAST_CMP,
834 methods::INTO_ITER_ON_REF,
835 methods::ITER_CLONED_COLLECT,
836 methods::ITER_SKIP_NEXT,
837 methods::NEW_RET_NO_SELF,
839 methods::OPTION_MAP_OR_NONE,
840 methods::SHOULD_IMPLEMENT_TRAIT,
841 methods::STRING_EXTEND_CHARS,
842 methods::UNNECESSARY_FOLD,
843 methods::WRONG_SELF_CONVENTION,
844 misc::REDUNDANT_PATTERN,
845 misc::TOPLEVEL_REF_ARG,
847 misc_early::BUILTIN_TYPE_SHADOW,
848 misc_early::DOUBLE_NEG,
849 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
850 misc_early::MIXED_CASE_HEX_LITERALS,
851 misc_early::UNNEEDED_FIELD_PATTERN,
852 mut_reference::UNNECESSARY_MUT_PASSED,
853 neg_multiply::NEG_MULTIPLY,
854 new_without_default::NEW_WITHOUT_DEFAULT,
855 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
856 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
857 ok_if_let::IF_LET_SOME_RESULT,
858 panic_unimplemented::PANIC_PARAMS,
861 question_mark::QUESTION_MARK,
862 redundant_field_names::REDUNDANT_FIELD_NAMES,
863 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
865 regex::TRIVIAL_REGEX,
866 returns::LET_AND_RETURN,
867 returns::NEEDLESS_RETURN,
868 returns::UNUSED_UNIT,
869 strings::STRING_LIT_AS_BYTES,
870 types::FN_TO_NUMERIC_CAST,
871 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
872 types::IMPLICIT_HASHER,
873 types::LET_UNIT_VALUE,
874 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
875 write::PRINTLN_EMPTY_STRING,
876 write::PRINT_LITERAL,
877 write::PRINT_WITH_NEWLINE,
878 write::WRITELN_EMPTY_STRING,
879 write::WRITE_LITERAL,
880 write::WRITE_WITH_NEWLINE,
883 reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
884 assign_ops::MISREFACTORED_ASSIGN_OP,
885 attrs::DEPRECATED_CFG_ATTR,
886 booleans::NONMINIMAL_BOOL,
887 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
888 double_comparison::DOUBLE_COMPARISONS,
889 double_parens::DOUBLE_PARENS,
890 duration_subsec::DURATION_SUBSEC,
891 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
892 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
893 explicit_write::EXPLICIT_WRITE,
894 format::USELESS_FORMAT,
895 functions::TOO_MANY_ARGUMENTS,
896 identity_conversion::IDENTITY_CONVERSION,
897 identity_op::IDENTITY_OP,
898 int_plus_one::INT_PLUS_ONE,
899 lifetimes::EXTRA_UNUSED_LIFETIMES,
900 lifetimes::NEEDLESS_LIFETIMES,
901 loops::EXPLICIT_COUNTER_LOOP,
902 loops::MUT_RANGE_BOUND,
903 loops::WHILE_LET_LOOP,
904 map_unit_fn::OPTION_MAP_UNIT_FN,
905 map_unit_fn::RESULT_MAP_UNIT_FN,
906 matches::MATCH_AS_REF,
907 methods::CHARS_NEXT_CMP,
908 methods::CLONE_ON_COPY,
909 methods::FILTER_NEXT,
910 methods::SEARCH_IS_SOME,
911 methods::UNNECESSARY_FILTER_MAP,
912 methods::USELESS_ASREF,
913 misc::SHORT_CIRCUIT_STATEMENT,
914 misc_early::REDUNDANT_CLOSURE_CALL,
915 misc_early::ZERO_PREFIXED_LITERAL,
916 needless_bool::BOOL_COMPARISON,
917 needless_bool::NEEDLESS_BOOL,
918 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
919 needless_update::NEEDLESS_UPDATE,
920 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
921 no_effect::NO_EFFECT,
922 no_effect::UNNECESSARY_OPERATION,
923 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
924 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
925 precedence::PRECEDENCE,
926 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
927 ranges::RANGE_MINUS_ONE,
928 ranges::RANGE_PLUS_ONE,
929 ranges::RANGE_ZIP_WITH_LEN,
930 reference::DEREF_ADDROF,
931 reference::REF_IN_DEREF,
933 temporary_assignment::TEMPORARY_ASSIGNMENT,
934 transmute::CROSSPOINTER_TRANSMUTE,
935 transmute::TRANSMUTE_BYTES_TO_STR,
936 transmute::TRANSMUTE_INT_TO_BOOL,
937 transmute::TRANSMUTE_INT_TO_CHAR,
938 transmute::TRANSMUTE_INT_TO_FLOAT,
939 transmute::TRANSMUTE_PTR_TO_PTR,
940 transmute::TRANSMUTE_PTR_TO_REF,
941 transmute::USELESS_TRANSMUTE,
943 types::CAST_LOSSLESS,
944 types::CHAR_LIT_AS_U8,
945 types::OPTION_OPTION,
946 types::TYPE_COMPLEXITY,
948 types::UNNECESSARY_CAST,
950 unused_label::UNUSED_LABEL,
951 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
954 reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
955 approx_const::APPROX_CONSTANT,
956 attrs::DEPRECATED_SEMVER,
957 attrs::USELESS_ATTRIBUTE,
958 bit_mask::BAD_BIT_MASK,
959 bit_mask::INEFFECTIVE_BIT_MASK,
961 copies::IFS_SAME_COND,
962 copies::IF_SAME_THEN_ELSE,
963 derive::DERIVE_HASH_XOR_EQ,
964 drop_forget_ref::DROP_COPY,
965 drop_forget_ref::DROP_REF,
966 drop_forget_ref::FORGET_COPY,
967 drop_forget_ref::FORGET_REF,
968 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
970 erasing_op::ERASING_OP,
971 formatting::POSSIBLE_MISSING_COMMA,
972 functions::NOT_UNSAFE_PTR_ARG_DEREF,
973 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
974 infinite_iter::INFINITE_ITER,
975 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
976 invalid_ref::INVALID_REF,
977 literal_representation::MISTYPED_LITERAL_SUFFIXES,
978 loops::FOR_LOOP_OVER_OPTION,
979 loops::FOR_LOOP_OVER_RESULT,
980 loops::ITER_NEXT_LOOP,
982 loops::REVERSE_RANGE_LOOP,
983 loops::WHILE_IMMUTABLE_CONDITION,
984 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
985 methods::CLONE_DOUBLE_REF,
986 methods::INTO_ITER_ON_ARRAY,
987 methods::TEMPORARY_CSTRING_AS_PTR,
992 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
993 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
994 open_options::NONSENSICAL_OPEN_OPTIONS,
996 ranges::ITERATOR_STEP_BY_ZERO,
997 regex::INVALID_REGEX,
998 serde_api::SERDE_API_MISUSE,
999 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
1000 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
1001 swap::ALMOST_SWAPPED,
1002 transmute::WRONG_TRANSMUTE,
1003 types::ABSURD_EXTREME_COMPARISONS,
1004 types::CAST_PTR_ALIGNMENT,
1005 types::CAST_REF_TO_MUT,
1007 unicode::ZERO_WIDTH_SPACE,
1008 unused_io_amount::UNUSED_IO_AMOUNT,
1011 reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
1012 bytecount::NAIVE_BYTECOUNT,
1014 escape::BOXED_LOCAL,
1015 large_enum_variant::LARGE_ENUM_VARIANT,
1016 loops::MANUAL_MEMCPY,
1017 loops::NEEDLESS_COLLECT,
1018 loops::UNUSED_COLLECT,
1019 methods::EXPECT_FUN_CALL,
1021 methods::OR_FUN_CALL,
1022 methods::SINGLE_CHAR_PATTERN,
1024 mutex_atomic::MUTEX_ATOMIC,
1025 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
1026 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
1031 reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
1032 cargo_common_metadata::CARGO_COMMON_METADATA,
1033 multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
1034 wildcard_dependencies::WILDCARD_DEPENDENCIES,
1037 reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
1038 attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
1039 fallible_impl_from::FALLIBLE_IMPL_FROM,
1040 missing_const_for_fn::MISSING_CONST_FOR_FN,
1041 mutex_atomic::MUTEX_INTEGER,
1042 needless_borrow::NEEDLESS_BORROW,
1043 redundant_clone::REDUNDANT_CLONE,
1044 unwrap::PANICKING_UNWRAP,
1045 unwrap::UNNECESSARY_UNWRAP,
1049 pub fn register_renamed(ls: &mut rustc::lint::LintStore) {
1050 ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions");
1051 ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
1054 // only exists to let the dogfood integration test works.
1055 // Don't run clippy as an executable directly
1058 panic!("Please use the cargo-clippy executable");