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)]
14 #![feature(if_while_or_patterns)]
16 // FIXME: switch to something more ergonomic here, once available.
17 // (currently there is no way to opt into sysroot crates w/o `extern crate`)
18 #[allow(unused_extern_crates)]
19 extern crate fmt_macros;
20 #[allow(unused_extern_crates)]
22 #[allow(unused_extern_crates)]
23 extern crate rustc_data_structures;
24 #[allow(unused_extern_crates)]
25 extern crate rustc_errors;
26 #[allow(unused_extern_crates)]
27 extern crate rustc_plugin;
28 #[allow(unused_extern_crates)]
29 extern crate rustc_target;
30 #[allow(unused_extern_crates)]
31 extern crate rustc_typeck;
32 #[allow(unused_extern_crates)]
34 #[allow(unused_extern_crates)]
35 extern crate syntax_pos;
39 // Currently, categories "style", "correctness", "complexity" and "perf" are enabled by default,
40 // as said in the README.md of this repository. If this changes, please update README.md.
42 macro_rules! declare_clippy_lint {
43 { pub $name:tt, style, $description:tt } => {
44 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
46 { pub $name:tt, correctness, $description:tt } => {
47 declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true }
49 { pub $name:tt, complexity, $description:tt } => {
50 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
52 { pub $name:tt, perf, $description:tt } => {
53 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
55 { pub $name:tt, pedantic, $description:tt } => {
56 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
58 { pub $name:tt, restriction, $description:tt } => {
59 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
61 { pub $name:tt, cargo, $description:tt } => {
62 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
64 { pub $name:tt, nursery, $description:tt } => {
65 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
67 { pub $name:tt, internal, $description:tt } => {
68 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
70 { pub $name:tt, internal_warn, $description:tt } => {
71 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
79 // begin lints modules, do not remove this comment, it’s used in `update_lints`
85 pub mod blacklisted_name;
86 pub mod block_in_if_condition;
89 pub mod cargo_common_metadata;
90 pub mod collapsible_if;
91 pub mod const_static_lifetime;
93 pub mod copy_iterator;
94 pub mod cyclomatic_complexity;
95 pub mod default_trait_access;
98 pub mod double_comparison;
99 pub mod double_parens;
100 pub mod drop_forget_ref;
101 pub mod duration_subsec;
102 pub mod else_if_without_else;
106 pub mod enum_glob_use;
107 pub mod enum_variants;
111 pub mod eta_reduction;
112 pub mod eval_order_dependence;
113 pub mod excessive_precision;
114 pub mod explicit_write;
115 pub mod fallible_impl_from;
119 pub mod identity_conversion;
122 pub mod implicit_return;
123 pub mod indexing_slicing;
124 pub mod infallible_destructuring_match;
125 pub mod infinite_iter;
126 pub mod inherent_impl;
127 pub mod inline_fn_without_body;
128 pub mod int_plus_one;
130 pub mod items_after_statements;
131 pub mod large_enum_variant;
135 pub mod literal_representation;
140 pub mod mem_discriminant;
148 pub mod missing_inline;
149 pub mod multiple_crate_versions;
151 pub mod mut_reference;
152 pub mod mutex_atomic;
153 pub mod needless_bool;
154 pub mod needless_borrow;
155 pub mod needless_borrowed_ref;
156 pub mod needless_continue;
157 pub mod needless_pass_by_value;
158 pub mod needless_update;
159 pub mod neg_cmp_op_on_partial_ord;
160 pub mod neg_multiply;
161 pub mod new_without_default;
163 pub mod non_copy_const;
164 pub mod non_expressive_names;
166 pub mod open_options;
167 pub mod overflow_check_conditional;
168 pub mod panic_unimplemented;
169 pub mod partialeq_ne_impl;
172 pub mod ptr_offset_with_cast;
173 pub mod question_mark;
175 pub mod redundant_clone;
176 pub mod redundant_field_names;
177 pub mod redundant_pattern_matching;
180 pub mod replace_consts;
184 pub mod slow_vector_initialization;
186 pub mod suspicious_trait_impl;
188 pub mod temporary_assignment;
190 pub mod trivially_copy_pass_by_ref;
193 pub mod unsafe_removed_from_name;
194 pub mod unused_io_amount;
195 pub mod unused_label;
199 pub mod wildcard_dependencies;
201 pub mod zero_div_zero;
202 // end lints modules, do not remove this comment, it’s used in `update_lints`
204 pub use crate::utils::conf::Conf;
207 crate use syntax::ast::{Name, NodeId};
210 pub fn register_pre_expansion_lints(
211 session: &rustc::session::Session,
212 store: &mut rustc::lint::LintStore,
215 store.register_pre_expansion_pass(Some(session), box write::Pass);
216 store.register_pre_expansion_pass(Some(session), box redundant_field_names::RedundantFieldNames);
217 store.register_pre_expansion_pass(
219 box non_expressive_names::NonExpressiveNames {
220 single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
223 store.register_pre_expansion_pass(Some(session), box attrs::CfgAttrPass);
226 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
227 match utils::conf::file_from_args(reg.args()) {
229 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
230 // do not require the file to exist
231 let file_name = if let Some(file_name) = file_name {
234 match utils::conf::lookup_conf_file() {
238 .struct_err(&format!("error finding Clippy's configuration file: {}", error))
245 let file_name = file_name.map(|file_name| {
246 if file_name.is_relative() {
248 .local_crate_source_file
250 .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
258 let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
260 // all conf errors are non-fatal, we just use the default conf in case of error
261 for error in errors {
263 .struct_err(&format!(
264 "error reading Clippy's configuration file `{}`: {}",
265 file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""),
273 Err((err, span)) => {
275 .struct_span_err(span, err)
276 .span_note(span, "Clippy will use default configuration")
278 toml::from_str("").expect("we never error on empty config files")
284 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
285 let mut store = reg.sess.lint_store.borrow_mut();
286 // begin deprecated lints, do not remove this comment, it’s used in `update_lints`
287 store.register_removed(
289 "`assert!()` will be more flexible with RFC 2011",
291 store.register_removed(
293 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
295 store.register_removed(
296 "range_step_by_zero",
297 "`iterator.step_by(0)` panics nowadays",
299 store.register_removed(
301 "`Vec::as_slice` has been stabilized in 1.7",
303 store.register_removed(
304 "unstable_as_mut_slice",
305 "`Vec::as_mut_slice` has been stabilized in 1.7",
307 store.register_removed(
309 "using `str::to_string` is common even today and specialization will likely happen soon",
311 store.register_removed(
313 "using `string::to_string` is common even today and specialization will likely happen soon",
315 store.register_removed(
316 "misaligned_transmute",
317 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
319 store.register_removed(
321 "using compound assignment operators (e.g. `+=`) is harmless",
323 store.register_removed(
324 "if_let_redundant_pattern_matching",
325 "this lint has been changed to redundant_pattern_matching",
327 store.register_removed(
328 "unsafe_vector_initialization",
329 "the replacement suggested by this lint had substantially different behavior",
331 // end deprecated lints, do not remove this comment, it’s used in `update_lints`
333 reg.register_late_lint_pass(box serde_api::Serde);
334 reg.register_early_lint_pass(box utils::internal_lints::Clippy);
335 reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
336 reg.register_early_lint_pass(box utils::internal_lints::DefaultHashTypes::default());
337 reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
338 reg.register_late_lint_pass(box utils::inspector::Pass);
339 reg.register_late_lint_pass(box utils::author::Pass);
340 reg.register_late_lint_pass(box types::TypePass);
341 reg.register_late_lint_pass(box booleans::NonminimalBool);
342 reg.register_late_lint_pass(box eq_op::EqOp);
343 reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
344 reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
345 reg.register_late_lint_pass(box enum_clike::UnportableVariant);
346 reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
347 reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
348 reg.register_late_lint_pass(box ptr::PointerPass);
349 reg.register_late_lint_pass(box needless_bool::NeedlessBool);
350 reg.register_late_lint_pass(box needless_bool::BoolComparison);
351 reg.register_late_lint_pass(box approx_const::Pass);
352 reg.register_late_lint_pass(box misc::Pass);
353 reg.register_early_lint_pass(box precedence::Precedence);
354 reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
355 reg.register_late_lint_pass(box eta_reduction::EtaPass);
356 reg.register_late_lint_pass(box identity_op::IdentityOp);
357 reg.register_late_lint_pass(box erasing_op::ErasingOp);
358 reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
359 reg.register_late_lint_pass(box mut_mut::MutMut);
360 reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
361 reg.register_late_lint_pass(box len_zero::LenZero);
362 reg.register_late_lint_pass(box attrs::AttrPass);
363 reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
364 reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
365 reg.register_late_lint_pass(box unicode::Unicode);
366 reg.register_late_lint_pass(box strings::StringAdd);
367 reg.register_early_lint_pass(box returns::ReturnPass);
368 reg.register_late_lint_pass(box implicit_return::Pass);
369 reg.register_late_lint_pass(box methods::Pass);
370 reg.register_late_lint_pass(box map_clone::Pass);
371 reg.register_late_lint_pass(box shadow::Pass);
372 reg.register_late_lint_pass(box types::LetPass);
373 reg.register_late_lint_pass(box types::UnitCmp);
374 reg.register_late_lint_pass(box loops::Pass);
375 reg.register_late_lint_pass(box lifetimes::LifetimePass);
376 reg.register_late_lint_pass(box entry::HashMapLint);
377 reg.register_late_lint_pass(box ranges::Pass);
378 reg.register_late_lint_pass(box types::CastPass);
379 reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
380 reg.register_late_lint_pass(box matches::MatchPass);
381 reg.register_late_lint_pass(box minmax::MinMaxPass);
382 reg.register_late_lint_pass(box open_options::NonSensical);
383 reg.register_late_lint_pass(box zero_div_zero::Pass);
384 reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
385 reg.register_late_lint_pass(box needless_update::Pass);
386 reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow::default());
387 reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
388 reg.register_late_lint_pass(box no_effect::Pass);
389 reg.register_late_lint_pass(box temporary_assignment::Pass);
390 reg.register_late_lint_pass(box transmute::Transmute);
391 reg.register_late_lint_pass(
392 box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
394 reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
395 reg.register_early_lint_pass(box misc_early::MiscEarly);
396 reg.register_late_lint_pass(box panic_unimplemented::Pass);
397 reg.register_late_lint_pass(box strings::StringLitAsBytes);
398 reg.register_late_lint_pass(box derive::Derive);
399 reg.register_late_lint_pass(box types::CharLitAsU8);
400 reg.register_late_lint_pass(box vec::Pass);
401 reg.register_late_lint_pass(box drop_forget_ref::Pass);
402 reg.register_late_lint_pass(box empty_enum::EmptyEnum);
403 reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
404 reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
405 reg.register_late_lint_pass(box regex::Pass::default());
406 reg.register_late_lint_pass(box copies::CopyAndPaste);
407 reg.register_late_lint_pass(box copy_iterator::CopyIterator);
408 reg.register_late_lint_pass(box format::Pass);
409 reg.register_early_lint_pass(box formatting::Formatting);
410 reg.register_late_lint_pass(box swap::Swap);
411 reg.register_early_lint_pass(box if_not_else::IfNotElse);
412 reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
413 reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
414 reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
415 reg.register_late_lint_pass(box unused_label::UnusedLabel);
416 reg.register_late_lint_pass(box new_without_default::NewWithoutDefault::default());
417 reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(
418 conf.blacklisted_names.iter().cloned().collect()
420 reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold));
421 reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents.iter().cloned().collect()));
422 reg.register_late_lint_pass(box neg_multiply::NegMultiply);
423 reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
424 reg.register_late_lint_pass(box mem_discriminant::MemDiscriminant);
425 reg.register_late_lint_pass(box mem_forget::MemForget);
426 reg.register_late_lint_pass(box mem_replace::MemReplace);
427 reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
428 reg.register_late_lint_pass(box assign_ops::AssignOps);
429 reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
430 reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
431 reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
432 reg.register_late_lint_pass(box missing_inline::MissingInline);
433 reg.register_late_lint_pass(box ok_if_let::Pass);
434 reg.register_late_lint_pass(box redundant_pattern_matching::Pass);
435 reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
436 reg.register_early_lint_pass(box reference::Pass);
437 reg.register_early_lint_pass(box reference::DerefPass);
438 reg.register_early_lint_pass(box double_parens::DoubleParens);
439 reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
440 reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
441 reg.register_late_lint_pass(box explicit_write::Pass);
442 reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
443 reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
444 conf.trivial_copy_size_limit,
447 reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
448 reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
449 conf.literal_representation_threshold
451 reg.register_late_lint_pass(box use_self::UseSelf);
452 reg.register_late_lint_pass(box bytecount::ByteCount);
453 reg.register_late_lint_pass(box infinite_iter::Pass);
454 reg.register_late_lint_pass(box inline_fn_without_body::Pass);
455 reg.register_late_lint_pass(box invalid_ref::InvalidRef);
456 reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
457 reg.register_late_lint_pass(box types::ImplicitHasher);
458 reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
459 reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
460 reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
461 reg.register_late_lint_pass(box types::UnitArg);
462 reg.register_late_lint_pass(box double_comparison::Pass);
463 reg.register_late_lint_pass(box question_mark::Pass);
464 reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
465 reg.register_early_lint_pass(box cargo_common_metadata::Pass);
466 reg.register_early_lint_pass(box multiple_crate_versions::Pass);
467 reg.register_early_lint_pass(box wildcard_dependencies::Pass);
468 reg.register_late_lint_pass(box map_unit_fn::Pass);
469 reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
470 reg.register_late_lint_pass(box inherent_impl::Pass::default());
471 reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
472 reg.register_late_lint_pass(box unwrap::Pass);
473 reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
474 reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
475 reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
476 reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
477 reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
478 reg.register_late_lint_pass(box redundant_clone::RedundantClone);
479 reg.register_late_lint_pass(box slow_vector_initialization::Pass);
480 reg.register_late_lint_pass(box types::RefToMut);
482 reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
483 arithmetic::FLOAT_ARITHMETIC,
484 arithmetic::INTEGER_ARITHMETIC,
485 else_if_without_else::ELSE_IF_WITHOUT_ELSE,
486 implicit_return::IMPLICIT_RETURN,
487 indexing_slicing::INDEXING_SLICING,
488 inherent_impl::MULTIPLE_INHERENT_IMPL,
489 literal_representation::DECIMAL_LITERAL_REPRESENTATION,
490 mem_forget::MEM_FORGET,
491 methods::CLONE_ON_REF_PTR,
492 methods::OPTION_UNWRAP_USED,
493 methods::RESULT_UNWRAP_USED,
494 methods::WRONG_PUB_SELF_CONVENTION,
495 misc::FLOAT_CMP_CONST,
496 missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
497 missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
498 panic_unimplemented::UNIMPLEMENTED,
499 shadow::SHADOW_REUSE,
506 reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
507 attrs::INLINE_ALWAYS,
508 copies::MATCH_SAME_ARMS,
509 copy_iterator::COPY_ITERATOR,
510 default_trait_access::DEFAULT_TRAIT_ACCESS,
511 derive::EXPL_IMPL_CLONE_ON_COPY,
513 empty_enum::EMPTY_ENUM,
514 enum_glob_use::ENUM_GLOB_USE,
515 enum_variants::MODULE_NAME_REPETITIONS,
516 enum_variants::PUB_ENUM_VARIANT_NAMES,
517 if_not_else::IF_NOT_ELSE,
518 infinite_iter::MAYBE_INFINITE_ITER,
519 items_after_statements::ITEMS_AFTER_STATEMENTS,
520 literal_representation::LARGE_DIGIT_GROUPS,
521 loops::EXPLICIT_INTO_ITER_LOOP,
522 loops::EXPLICIT_ITER_LOOP,
523 matches::SINGLE_MATCH_ELSE,
525 methods::MAP_FLATTEN,
526 methods::OPTION_MAP_UNWRAP_OR,
527 methods::OPTION_MAP_UNWRAP_OR_ELSE,
528 methods::RESULT_MAP_UNWRAP_OR_ELSE,
529 misc::USED_UNDERSCORE_BINDING,
530 misc_early::UNSEPARATED_LITERAL_SUFFIX,
532 needless_continue::NEEDLESS_CONTINUE,
533 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
534 non_expressive_names::SIMILAR_NAMES,
535 replace_consts::REPLACE_CONSTS,
536 shadow::SHADOW_UNRELATED,
537 strings::STRING_ADD_ASSIGN,
538 types::CAST_POSSIBLE_TRUNCATION,
539 types::CAST_POSSIBLE_WRAP,
540 types::CAST_PRECISION_LOSS,
541 types::CAST_SIGN_LOSS,
542 types::INVALID_UPCAST_COMPARISONS,
544 unicode::NON_ASCII_LITERAL,
545 unicode::UNICODE_NOT_NFC,
549 reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
550 utils::internal_lints::CLIPPY_LINTS_INTERNAL,
551 utils::internal_lints::COMPILER_LINT_FUNCTIONS,
552 utils::internal_lints::DEFAULT_HASH_TYPES,
553 utils::internal_lints::LINT_WITHOUT_LINT_PASS,
556 reg.register_lint_group("clippy::all", Some("clippy"), vec![
557 approx_const::APPROX_CONSTANT,
558 assign_ops::ASSIGN_OP_PATTERN,
559 assign_ops::MISREFACTORED_ASSIGN_OP,
560 attrs::DEPRECATED_CFG_ATTR,
561 attrs::DEPRECATED_SEMVER,
562 attrs::UNKNOWN_CLIPPY_LINTS,
563 attrs::USELESS_ATTRIBUTE,
564 bit_mask::BAD_BIT_MASK,
565 bit_mask::INEFFECTIVE_BIT_MASK,
566 bit_mask::VERBOSE_BIT_MASK,
567 blacklisted_name::BLACKLISTED_NAME,
568 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
569 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
571 booleans::NONMINIMAL_BOOL,
572 bytecount::NAIVE_BYTECOUNT,
573 collapsible_if::COLLAPSIBLE_IF,
574 const_static_lifetime::CONST_STATIC_LIFETIME,
575 copies::IFS_SAME_COND,
576 copies::IF_SAME_THEN_ELSE,
577 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
578 derive::DERIVE_HASH_XOR_EQ,
579 double_comparison::DOUBLE_COMPARISONS,
580 double_parens::DOUBLE_PARENS,
581 drop_forget_ref::DROP_COPY,
582 drop_forget_ref::DROP_REF,
583 drop_forget_ref::FORGET_COPY,
584 drop_forget_ref::FORGET_REF,
585 duration_subsec::DURATION_SUBSEC,
587 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
588 enum_variants::ENUM_VARIANT_NAMES,
589 enum_variants::MODULE_INCEPTION,
592 erasing_op::ERASING_OP,
594 eta_reduction::REDUNDANT_CLOSURE,
595 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
596 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
597 excessive_precision::EXCESSIVE_PRECISION,
598 explicit_write::EXPLICIT_WRITE,
599 format::USELESS_FORMAT,
600 formatting::POSSIBLE_MISSING_COMMA,
601 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
602 formatting::SUSPICIOUS_ELSE_FORMATTING,
603 functions::NOT_UNSAFE_PTR_ARG_DEREF,
604 functions::TOO_MANY_ARGUMENTS,
605 identity_conversion::IDENTITY_CONVERSION,
606 identity_op::IDENTITY_OP,
607 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
608 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
609 infinite_iter::INFINITE_ITER,
610 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
611 int_plus_one::INT_PLUS_ONE,
612 invalid_ref::INVALID_REF,
613 large_enum_variant::LARGE_ENUM_VARIANT,
614 len_zero::LEN_WITHOUT_IS_EMPTY,
616 let_if_seq::USELESS_LET_IF_SEQ,
617 lifetimes::EXTRA_UNUSED_LIFETIMES,
618 lifetimes::NEEDLESS_LIFETIMES,
619 literal_representation::INCONSISTENT_DIGIT_GROUPING,
620 literal_representation::MISTYPED_LITERAL_SUFFIXES,
621 literal_representation::UNREADABLE_LITERAL,
623 loops::EXPLICIT_COUNTER_LOOP,
625 loops::FOR_LOOP_OVER_OPTION,
626 loops::FOR_LOOP_OVER_RESULT,
627 loops::ITER_NEXT_LOOP,
628 loops::MANUAL_MEMCPY,
629 loops::MUT_RANGE_BOUND,
630 loops::NEEDLESS_COLLECT,
631 loops::NEEDLESS_RANGE_LOOP,
633 loops::REVERSE_RANGE_LOOP,
634 loops::UNUSED_COLLECT,
635 loops::WHILE_IMMUTABLE_CONDITION,
636 loops::WHILE_LET_LOOP,
637 loops::WHILE_LET_ON_ITERATOR,
638 map_clone::MAP_CLONE,
639 map_unit_fn::OPTION_MAP_UNIT_FN,
640 map_unit_fn::RESULT_MAP_UNIT_FN,
641 matches::MATCH_AS_REF,
643 matches::MATCH_OVERLAPPING_ARM,
644 matches::MATCH_REF_PATS,
645 matches::MATCH_WILD_ERR_ARM,
646 matches::SINGLE_MATCH,
647 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
648 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
649 methods::CHARS_LAST_CMP,
650 methods::CHARS_NEXT_CMP,
651 methods::CLONE_DOUBLE_REF,
652 methods::CLONE_ON_COPY,
653 methods::EXPECT_FUN_CALL,
654 methods::FILTER_NEXT,
656 methods::INTO_ITER_ON_ARRAY,
657 methods::INTO_ITER_ON_REF,
658 methods::ITER_CLONED_COLLECT,
660 methods::ITER_SKIP_NEXT,
661 methods::NEW_RET_NO_SELF,
663 methods::OPTION_MAP_OR_NONE,
664 methods::OR_FUN_CALL,
665 methods::SEARCH_IS_SOME,
666 methods::SHOULD_IMPLEMENT_TRAIT,
667 methods::SINGLE_CHAR_PATTERN,
668 methods::STRING_EXTEND_CHARS,
669 methods::TEMPORARY_CSTRING_AS_PTR,
670 methods::UNNECESSARY_FILTER_MAP,
671 methods::UNNECESSARY_FOLD,
672 methods::USELESS_ASREF,
673 methods::WRONG_SELF_CONVENTION,
679 misc::REDUNDANT_PATTERN,
680 misc::SHORT_CIRCUIT_STATEMENT,
681 misc::TOPLEVEL_REF_ARG,
683 misc_early::BUILTIN_TYPE_SHADOW,
684 misc_early::DOUBLE_NEG,
685 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
686 misc_early::MIXED_CASE_HEX_LITERALS,
687 misc_early::REDUNDANT_CLOSURE_CALL,
688 misc_early::UNNEEDED_FIELD_PATTERN,
689 misc_early::ZERO_PREFIXED_LITERAL,
690 mut_reference::UNNECESSARY_MUT_PASSED,
691 mutex_atomic::MUTEX_ATOMIC,
692 needless_bool::BOOL_COMPARISON,
693 needless_bool::NEEDLESS_BOOL,
694 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
695 needless_update::NEEDLESS_UPDATE,
696 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
697 neg_multiply::NEG_MULTIPLY,
698 new_without_default::NEW_WITHOUT_DEFAULT,
699 no_effect::NO_EFFECT,
700 no_effect::UNNECESSARY_OPERATION,
701 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
702 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
703 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
704 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
705 ok_if_let::IF_LET_SOME_RESULT,
706 open_options::NONSENSICAL_OPEN_OPTIONS,
707 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
708 panic_unimplemented::PANIC_PARAMS,
709 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
710 precedence::PRECEDENCE,
714 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
715 question_mark::QUESTION_MARK,
716 ranges::ITERATOR_STEP_BY_ZERO,
717 ranges::RANGE_MINUS_ONE,
718 ranges::RANGE_PLUS_ONE,
719 ranges::RANGE_ZIP_WITH_LEN,
720 redundant_field_names::REDUNDANT_FIELD_NAMES,
721 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
722 reference::DEREF_ADDROF,
723 reference::REF_IN_DEREF,
724 regex::INVALID_REGEX,
726 regex::TRIVIAL_REGEX,
727 returns::LET_AND_RETURN,
728 returns::NEEDLESS_RETURN,
729 returns::UNUSED_UNIT,
730 serde_api::SERDE_API_MISUSE,
731 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
732 strings::STRING_LIT_AS_BYTES,
733 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
734 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
735 swap::ALMOST_SWAPPED,
737 temporary_assignment::TEMPORARY_ASSIGNMENT,
738 transmute::CROSSPOINTER_TRANSMUTE,
739 transmute::TRANSMUTE_BYTES_TO_STR,
740 transmute::TRANSMUTE_INT_TO_BOOL,
741 transmute::TRANSMUTE_INT_TO_CHAR,
742 transmute::TRANSMUTE_INT_TO_FLOAT,
743 transmute::TRANSMUTE_PTR_TO_PTR,
744 transmute::TRANSMUTE_PTR_TO_REF,
745 transmute::USELESS_TRANSMUTE,
746 transmute::WRONG_TRANSMUTE,
747 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
748 types::ABSURD_EXTREME_COMPARISONS,
751 types::CAST_LOSSLESS,
752 types::CAST_PTR_ALIGNMENT,
753 types::CAST_REF_TO_MUT,
754 types::CHAR_LIT_AS_U8,
755 types::FN_TO_NUMERIC_CAST,
756 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
757 types::IMPLICIT_HASHER,
758 types::LET_UNIT_VALUE,
759 types::OPTION_OPTION,
760 types::TYPE_COMPLEXITY,
763 types::UNNECESSARY_CAST,
765 unicode::ZERO_WIDTH_SPACE,
766 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
767 unused_io_amount::UNUSED_IO_AMOUNT,
768 unused_label::UNUSED_LABEL,
770 write::PRINTLN_EMPTY_STRING,
771 write::PRINT_LITERAL,
772 write::PRINT_WITH_NEWLINE,
773 write::WRITELN_EMPTY_STRING,
774 write::WRITE_LITERAL,
775 write::WRITE_WITH_NEWLINE,
776 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
779 reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
780 assign_ops::ASSIGN_OP_PATTERN,
781 attrs::UNKNOWN_CLIPPY_LINTS,
782 bit_mask::VERBOSE_BIT_MASK,
783 blacklisted_name::BLACKLISTED_NAME,
784 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
785 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
786 collapsible_if::COLLAPSIBLE_IF,
787 const_static_lifetime::CONST_STATIC_LIFETIME,
788 enum_variants::ENUM_VARIANT_NAMES,
789 enum_variants::MODULE_INCEPTION,
791 eta_reduction::REDUNDANT_CLOSURE,
792 excessive_precision::EXCESSIVE_PRECISION,
793 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
794 formatting::SUSPICIOUS_ELSE_FORMATTING,
795 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
796 len_zero::LEN_WITHOUT_IS_EMPTY,
798 let_if_seq::USELESS_LET_IF_SEQ,
799 literal_representation::INCONSISTENT_DIGIT_GROUPING,
800 literal_representation::UNREADABLE_LITERAL,
803 loops::NEEDLESS_RANGE_LOOP,
804 loops::WHILE_LET_ON_ITERATOR,
805 map_clone::MAP_CLONE,
807 matches::MATCH_OVERLAPPING_ARM,
808 matches::MATCH_REF_PATS,
809 matches::MATCH_WILD_ERR_ARM,
810 matches::SINGLE_MATCH,
811 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
812 methods::CHARS_LAST_CMP,
814 methods::INTO_ITER_ON_REF,
815 methods::ITER_CLONED_COLLECT,
816 methods::ITER_SKIP_NEXT,
817 methods::NEW_RET_NO_SELF,
819 methods::OPTION_MAP_OR_NONE,
820 methods::SHOULD_IMPLEMENT_TRAIT,
821 methods::STRING_EXTEND_CHARS,
822 methods::UNNECESSARY_FOLD,
823 methods::WRONG_SELF_CONVENTION,
824 misc::REDUNDANT_PATTERN,
825 misc::TOPLEVEL_REF_ARG,
827 misc_early::BUILTIN_TYPE_SHADOW,
828 misc_early::DOUBLE_NEG,
829 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
830 misc_early::MIXED_CASE_HEX_LITERALS,
831 misc_early::UNNEEDED_FIELD_PATTERN,
832 mut_reference::UNNECESSARY_MUT_PASSED,
833 neg_multiply::NEG_MULTIPLY,
834 new_without_default::NEW_WITHOUT_DEFAULT,
835 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
836 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
837 ok_if_let::IF_LET_SOME_RESULT,
838 panic_unimplemented::PANIC_PARAMS,
841 question_mark::QUESTION_MARK,
842 redundant_field_names::REDUNDANT_FIELD_NAMES,
843 redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
845 regex::TRIVIAL_REGEX,
846 returns::LET_AND_RETURN,
847 returns::NEEDLESS_RETURN,
848 returns::UNUSED_UNIT,
849 strings::STRING_LIT_AS_BYTES,
850 types::FN_TO_NUMERIC_CAST,
851 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
852 types::IMPLICIT_HASHER,
853 types::LET_UNIT_VALUE,
854 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
855 write::PRINTLN_EMPTY_STRING,
856 write::PRINT_LITERAL,
857 write::PRINT_WITH_NEWLINE,
858 write::WRITELN_EMPTY_STRING,
859 write::WRITE_LITERAL,
860 write::WRITE_WITH_NEWLINE,
863 reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
864 assign_ops::MISREFACTORED_ASSIGN_OP,
865 attrs::DEPRECATED_CFG_ATTR,
866 booleans::NONMINIMAL_BOOL,
867 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
868 double_comparison::DOUBLE_COMPARISONS,
869 double_parens::DOUBLE_PARENS,
870 duration_subsec::DURATION_SUBSEC,
871 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
872 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
873 explicit_write::EXPLICIT_WRITE,
874 format::USELESS_FORMAT,
875 functions::TOO_MANY_ARGUMENTS,
876 identity_conversion::IDENTITY_CONVERSION,
877 identity_op::IDENTITY_OP,
878 int_plus_one::INT_PLUS_ONE,
879 lifetimes::EXTRA_UNUSED_LIFETIMES,
880 lifetimes::NEEDLESS_LIFETIMES,
881 loops::EXPLICIT_COUNTER_LOOP,
882 loops::MUT_RANGE_BOUND,
883 loops::WHILE_LET_LOOP,
884 map_unit_fn::OPTION_MAP_UNIT_FN,
885 map_unit_fn::RESULT_MAP_UNIT_FN,
886 matches::MATCH_AS_REF,
887 methods::CHARS_NEXT_CMP,
888 methods::CLONE_ON_COPY,
889 methods::FILTER_NEXT,
890 methods::SEARCH_IS_SOME,
891 methods::UNNECESSARY_FILTER_MAP,
892 methods::USELESS_ASREF,
893 misc::SHORT_CIRCUIT_STATEMENT,
894 misc_early::REDUNDANT_CLOSURE_CALL,
895 misc_early::ZERO_PREFIXED_LITERAL,
896 needless_bool::BOOL_COMPARISON,
897 needless_bool::NEEDLESS_BOOL,
898 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
899 needless_update::NEEDLESS_UPDATE,
900 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
901 no_effect::NO_EFFECT,
902 no_effect::UNNECESSARY_OPERATION,
903 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
904 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
905 precedence::PRECEDENCE,
906 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
907 ranges::RANGE_MINUS_ONE,
908 ranges::RANGE_PLUS_ONE,
909 ranges::RANGE_ZIP_WITH_LEN,
910 reference::DEREF_ADDROF,
911 reference::REF_IN_DEREF,
913 temporary_assignment::TEMPORARY_ASSIGNMENT,
914 transmute::CROSSPOINTER_TRANSMUTE,
915 transmute::TRANSMUTE_BYTES_TO_STR,
916 transmute::TRANSMUTE_INT_TO_BOOL,
917 transmute::TRANSMUTE_INT_TO_CHAR,
918 transmute::TRANSMUTE_INT_TO_FLOAT,
919 transmute::TRANSMUTE_PTR_TO_PTR,
920 transmute::TRANSMUTE_PTR_TO_REF,
921 transmute::USELESS_TRANSMUTE,
923 types::CAST_LOSSLESS,
924 types::CHAR_LIT_AS_U8,
925 types::OPTION_OPTION,
926 types::TYPE_COMPLEXITY,
928 types::UNNECESSARY_CAST,
930 unused_label::UNUSED_LABEL,
931 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
934 reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
935 approx_const::APPROX_CONSTANT,
936 attrs::DEPRECATED_SEMVER,
937 attrs::USELESS_ATTRIBUTE,
938 bit_mask::BAD_BIT_MASK,
939 bit_mask::INEFFECTIVE_BIT_MASK,
941 copies::IFS_SAME_COND,
942 copies::IF_SAME_THEN_ELSE,
943 derive::DERIVE_HASH_XOR_EQ,
944 drop_forget_ref::DROP_COPY,
945 drop_forget_ref::DROP_REF,
946 drop_forget_ref::FORGET_COPY,
947 drop_forget_ref::FORGET_REF,
948 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
950 erasing_op::ERASING_OP,
951 formatting::POSSIBLE_MISSING_COMMA,
952 functions::NOT_UNSAFE_PTR_ARG_DEREF,
953 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
954 infinite_iter::INFINITE_ITER,
955 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
956 invalid_ref::INVALID_REF,
957 literal_representation::MISTYPED_LITERAL_SUFFIXES,
958 loops::FOR_LOOP_OVER_OPTION,
959 loops::FOR_LOOP_OVER_RESULT,
960 loops::ITER_NEXT_LOOP,
962 loops::REVERSE_RANGE_LOOP,
963 loops::WHILE_IMMUTABLE_CONDITION,
964 mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
965 methods::CLONE_DOUBLE_REF,
966 methods::INTO_ITER_ON_ARRAY,
967 methods::TEMPORARY_CSTRING_AS_PTR,
972 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
973 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
974 open_options::NONSENSICAL_OPEN_OPTIONS,
976 ranges::ITERATOR_STEP_BY_ZERO,
977 regex::INVALID_REGEX,
978 serde_api::SERDE_API_MISUSE,
979 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
980 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
981 swap::ALMOST_SWAPPED,
982 transmute::WRONG_TRANSMUTE,
983 types::ABSURD_EXTREME_COMPARISONS,
984 types::CAST_PTR_ALIGNMENT,
985 types::CAST_REF_TO_MUT,
987 unicode::ZERO_WIDTH_SPACE,
988 unused_io_amount::UNUSED_IO_AMOUNT,
991 reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
992 bytecount::NAIVE_BYTECOUNT,
995 large_enum_variant::LARGE_ENUM_VARIANT,
996 loops::MANUAL_MEMCPY,
997 loops::NEEDLESS_COLLECT,
998 loops::UNUSED_COLLECT,
999 methods::EXPECT_FUN_CALL,
1001 methods::OR_FUN_CALL,
1002 methods::SINGLE_CHAR_PATTERN,
1004 mutex_atomic::MUTEX_ATOMIC,
1005 slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
1006 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
1011 reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
1012 cargo_common_metadata::CARGO_COMMON_METADATA,
1013 multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
1014 wildcard_dependencies::WILDCARD_DEPENDENCIES,
1017 reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
1018 attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
1019 fallible_impl_from::FALLIBLE_IMPL_FROM,
1020 mutex_atomic::MUTEX_INTEGER,
1021 needless_borrow::NEEDLESS_BORROW,
1022 redundant_clone::REDUNDANT_CLONE,
1023 unwrap::PANICKING_UNWRAP,
1024 unwrap::UNNECESSARY_UNWRAP,
1028 pub fn register_renamed(ls: &mut rustc::lint::LintStore) {
1029 ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions");
1030 ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
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");