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 #![allow(unknown_lints, clippy::shadow_reuse, clippy::missing_docs_in_private_items)]
9 #![recursion_limit = "256"]
10 #![feature(macro_at_most_once_rep)]
11 #![feature(tool_lints)]
12 #![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)]
13 #![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_plugin;
27 #[allow(unused_extern_crates)]
28 extern crate rustc_target;
29 #[allow(unused_extern_crates)]
30 extern crate rustc_typeck;
31 #[allow(unused_extern_crates)]
33 #[allow(unused_extern_crates)]
34 extern crate syntax_pos;
38 macro_rules! declare_clippy_lint {
39 { pub $name:tt, style, $description:tt } => {
40 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
42 { pub $name:tt, correctness, $description:tt } => {
43 declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true }
45 { pub $name:tt, complexity, $description:tt } => {
46 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
48 { pub $name:tt, perf, $description:tt } => {
49 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
51 { pub $name:tt, pedantic, $description:tt } => {
52 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
54 { pub $name:tt, restriction, $description:tt } => {
55 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
57 { pub $name:tt, cargo, $description:tt } => {
58 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
60 { pub $name:tt, nursery, $description:tt } => {
61 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
63 { pub $name:tt, internal, $description:tt } => {
64 declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
66 { pub $name:tt, internal_warn, $description:tt } => {
67 declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
75 // begin lints modules, do not remove this comment, it’s used in `update_lints`
81 pub mod blacklisted_name;
82 pub mod block_in_if_condition;
85 pub mod collapsible_if;
86 pub mod const_static_lifetime;
88 pub mod copy_iterator;
89 pub mod cyclomatic_complexity;
90 pub mod default_trait_access;
93 pub mod double_comparison;
94 pub mod double_parens;
95 pub mod drop_forget_ref;
96 pub mod duration_subsec;
97 pub mod else_if_without_else;
101 pub mod enum_glob_use;
102 pub mod enum_variants;
106 pub mod eta_reduction;
107 pub mod eval_order_dependence;
108 pub mod excessive_precision;
109 pub mod explicit_write;
110 pub mod fallible_impl_from;
114 pub mod identity_conversion;
116 pub mod if_let_redundant_pattern_matching;
118 pub mod indexing_slicing;
119 pub mod infallible_destructuring_match;
120 pub mod infinite_iter;
121 pub mod inherent_impl;
122 pub mod inline_fn_without_body;
123 pub mod int_plus_one;
125 pub mod items_after_statements;
126 pub mod large_enum_variant;
130 pub mod literal_representation;
141 pub mod missing_inline;
142 pub mod multiple_crate_versions;
144 pub mod mut_reference;
145 pub mod mutex_atomic;
146 pub mod needless_bool;
147 pub mod needless_borrow;
148 pub mod needless_borrowed_ref;
149 pub mod needless_continue;
150 pub mod needless_pass_by_value;
151 pub mod needless_update;
152 pub mod neg_cmp_op_on_partial_ord;
153 pub mod neg_multiply;
154 pub mod new_without_default;
156 pub mod non_copy_const;
157 pub mod non_expressive_names;
159 pub mod open_options;
160 pub mod overflow_check_conditional;
161 pub mod panic_unimplemented;
162 pub mod partialeq_ne_impl;
165 pub mod ptr_offset_with_cast;
166 pub mod question_mark;
168 pub mod redundant_field_names;
171 pub mod replace_consts;
176 pub mod suspicious_trait_impl;
178 pub mod temporary_assignment;
180 pub mod trivially_copy_pass_by_ref;
183 pub mod unsafe_removed_from_name;
184 pub mod unused_io_amount;
185 pub mod unused_label;
190 pub mod zero_div_zero;
191 // end lints modules, do not remove this comment, it’s used in `update_lints`
193 pub use crate::utils::conf::Conf;
196 crate use crate::syntax::ast::{Name, NodeId};
199 pub fn register_pre_expansion_lints(session: &rustc::session::Session, store: &mut rustc::lint::LintStore, conf: &Conf) {
200 store.register_pre_expansion_pass(Some(session), box write::Pass);
201 store.register_pre_expansion_pass(Some(session), box redundant_field_names::RedundantFieldNames);
202 store.register_pre_expansion_pass(Some(session), box non_expressive_names::NonExpressiveNames {
203 single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
207 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
208 match utils::conf::file_from_args(reg.args()) {
210 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
211 // do not require the file to exist
212 let file_name = if let Some(file_name) = file_name {
215 match utils::conf::lookup_conf_file() {
218 reg.sess.struct_err(&format!("error finding Clippy's configuration file: {}", error)).emit();
224 let file_name = file_name.map(|file_name| if file_name.is_relative() {
226 .local_crate_source_file
228 .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
235 let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
237 // all conf errors are non-fatal, we just use the default conf in case of error
238 for error in errors {
239 reg.sess.struct_err(&format!("error reading Clippy's configuration file `{}`: {}", file_name.as_ref().and_then(|p| p.to_str()).unwrap_or(""), error)).emit();
244 Err((err, span)) => {
245 reg.sess.struct_span_err(span, err)
246 .span_note(span, "Clippy will use default configuration")
248 toml::from_str("").expect("we never error on empty config files")
254 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
255 let mut store = reg.sess.lint_store.borrow_mut();
256 store.register_removed(
258 "`assert!()` will be more flexible with RFC 2011",
260 store.register_removed(
262 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
264 store.register_removed(
265 "range_step_by_zero",
266 "`iterator.step_by(0)` panics nowadays",
268 store.register_removed(
270 "`Vec::as_slice` has been stabilized in 1.7",
272 store.register_removed(
273 "unstable_as_mut_slice",
274 "`Vec::as_mut_slice` has been stabilized in 1.7",
276 store.register_removed(
278 "using `str::to_string` is common even today and specialization will likely happen soon",
280 store.register_removed(
282 "using `string::to_string` is common even today and specialization will likely happen soon",
284 store.register_removed(
285 "misaligned_transmute",
286 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
288 store.register_removed(
290 "using compound assignment operators (e.g. `+=`) is harmless",
292 // end deprecated lints, do not remove this comment, it’s used in `update_lints`
294 reg.register_late_lint_pass(box serde_api::Serde);
295 reg.register_early_lint_pass(box utils::internal_lints::Clippy);
296 reg.register_late_lint_pass(box utils::internal_lints::CompilerLintFunctions::new());
297 reg.register_early_lint_pass(box utils::internal_lints::DefaultHashTypes::default());
298 reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
299 reg.register_late_lint_pass(box utils::inspector::Pass);
300 reg.register_late_lint_pass(box utils::author::Pass);
301 reg.register_late_lint_pass(box types::TypePass);
302 reg.register_late_lint_pass(box booleans::NonminimalBool);
303 reg.register_late_lint_pass(box eq_op::EqOp);
304 reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
305 reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
306 reg.register_late_lint_pass(box enum_clike::UnportableVariant);
307 reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
308 reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
309 reg.register_late_lint_pass(box ptr::PointerPass);
310 reg.register_late_lint_pass(box needless_bool::NeedlessBool);
311 reg.register_late_lint_pass(box needless_bool::BoolComparison);
312 reg.register_late_lint_pass(box approx_const::Pass);
313 reg.register_late_lint_pass(box misc::Pass);
314 reg.register_early_lint_pass(box precedence::Precedence);
315 reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
316 reg.register_late_lint_pass(box eta_reduction::EtaPass);
317 reg.register_late_lint_pass(box identity_op::IdentityOp);
318 reg.register_late_lint_pass(box erasing_op::ErasingOp);
319 reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
320 reg.register_late_lint_pass(box mut_mut::MutMut);
321 reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
322 reg.register_late_lint_pass(box len_zero::LenZero);
323 reg.register_late_lint_pass(box attrs::AttrPass);
324 reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
325 reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
326 reg.register_late_lint_pass(box unicode::Unicode);
327 reg.register_late_lint_pass(box strings::StringAdd);
328 reg.register_early_lint_pass(box returns::ReturnPass);
329 reg.register_late_lint_pass(box methods::Pass);
330 reg.register_late_lint_pass(box shadow::Pass);
331 reg.register_late_lint_pass(box types::LetPass);
332 reg.register_late_lint_pass(box types::UnitCmp);
333 reg.register_late_lint_pass(box loops::Pass);
334 reg.register_late_lint_pass(box lifetimes::LifetimePass);
335 reg.register_late_lint_pass(box entry::HashMapLint);
336 reg.register_late_lint_pass(box ranges::Pass);
337 reg.register_late_lint_pass(box types::CastPass);
338 reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
339 reg.register_late_lint_pass(box matches::MatchPass);
340 reg.register_late_lint_pass(box minmax::MinMaxPass);
341 reg.register_late_lint_pass(box open_options::NonSensical);
342 reg.register_late_lint_pass(box zero_div_zero::Pass);
343 reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
344 reg.register_late_lint_pass(box needless_update::Pass);
345 reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow);
346 reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
347 reg.register_late_lint_pass(box no_effect::Pass);
348 reg.register_late_lint_pass(box temporary_assignment::Pass);
349 reg.register_late_lint_pass(box transmute::Transmute);
350 reg.register_late_lint_pass(
351 box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
353 reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
354 reg.register_early_lint_pass(box misc_early::MiscEarly);
355 reg.register_late_lint_pass(box panic_unimplemented::Pass);
356 reg.register_late_lint_pass(box strings::StringLitAsBytes);
357 reg.register_late_lint_pass(box derive::Derive);
358 reg.register_late_lint_pass(box types::CharLitAsU8);
359 reg.register_late_lint_pass(box vec::Pass);
360 reg.register_late_lint_pass(box drop_forget_ref::Pass);
361 reg.register_late_lint_pass(box empty_enum::EmptyEnum);
362 reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
363 reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
364 reg.register_late_lint_pass(box regex::Pass::default());
365 reg.register_late_lint_pass(box copies::CopyAndPaste);
366 reg.register_late_lint_pass(box copy_iterator::CopyIterator);
367 reg.register_late_lint_pass(box format::Pass);
368 reg.register_early_lint_pass(box formatting::Formatting);
369 reg.register_late_lint_pass(box swap::Swap);
370 reg.register_early_lint_pass(box if_not_else::IfNotElse);
371 reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
372 reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
373 reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
374 reg.register_late_lint_pass(box unused_label::UnusedLabel);
375 reg.register_late_lint_pass(box new_without_default::NewWithoutDefault);
376 reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(conf.blacklisted_names.clone()));
377 reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold));
378 reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents.clone()));
379 reg.register_late_lint_pass(box neg_multiply::NegMultiply);
380 reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
381 reg.register_late_lint_pass(box mem_forget::MemForget);
382 reg.register_late_lint_pass(box mem_replace::MemReplace);
383 reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
384 reg.register_late_lint_pass(box assign_ops::AssignOps);
385 reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
386 reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
387 reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
388 reg.register_late_lint_pass(box missing_inline::MissingInline);
389 reg.register_late_lint_pass(box ok_if_let::Pass);
390 reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
391 reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
392 reg.register_early_lint_pass(box reference::Pass);
393 reg.register_early_lint_pass(box reference::DerefPass);
394 reg.register_early_lint_pass(box double_parens::DoubleParens);
395 reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
396 reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
397 reg.register_late_lint_pass(box explicit_write::Pass);
398 reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
399 reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
400 conf.trivial_copy_size_limit,
403 reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
404 reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
405 conf.literal_representation_threshold
407 reg.register_late_lint_pass(box use_self::UseSelf);
408 reg.register_late_lint_pass(box bytecount::ByteCount);
409 reg.register_late_lint_pass(box infinite_iter::Pass);
410 reg.register_late_lint_pass(box inline_fn_without_body::Pass);
411 reg.register_late_lint_pass(box invalid_ref::InvalidRef);
412 reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
413 reg.register_late_lint_pass(box types::ImplicitHasher);
414 reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
415 reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
416 reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
417 reg.register_late_lint_pass(box types::UnitArg);
418 reg.register_late_lint_pass(box double_comparison::DoubleComparisonPass);
419 reg.register_late_lint_pass(box question_mark::QuestionMarkPass);
420 reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
421 reg.register_early_lint_pass(box multiple_crate_versions::Pass);
422 reg.register_late_lint_pass(box map_unit_fn::Pass);
423 reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
424 reg.register_late_lint_pass(box inherent_impl::Pass::default());
425 reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
426 reg.register_late_lint_pass(box unwrap::Pass);
427 reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
428 reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
429 reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
430 reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
431 reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
433 reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
434 arithmetic::FLOAT_ARITHMETIC,
435 arithmetic::INTEGER_ARITHMETIC,
436 else_if_without_else::ELSE_IF_WITHOUT_ELSE,
437 indexing_slicing::INDEXING_SLICING,
438 inherent_impl::MULTIPLE_INHERENT_IMPL,
439 literal_representation::DECIMAL_LITERAL_REPRESENTATION,
440 mem_forget::MEM_FORGET,
441 methods::CLONE_ON_REF_PTR,
442 methods::OPTION_UNWRAP_USED,
443 methods::RESULT_UNWRAP_USED,
444 methods::WRONG_PUB_SELF_CONVENTION,
445 misc::FLOAT_CMP_CONST,
446 missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
447 missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
448 panic_unimplemented::UNIMPLEMENTED,
449 shadow::SHADOW_REUSE,
456 reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
457 attrs::INLINE_ALWAYS,
458 copies::MATCH_SAME_ARMS,
459 copy_iterator::COPY_ITERATOR,
460 default_trait_access::DEFAULT_TRAIT_ACCESS,
461 derive::EXPL_IMPL_CLONE_ON_COPY,
463 empty_enum::EMPTY_ENUM,
464 enum_glob_use::ENUM_GLOB_USE,
465 enum_variants::PUB_ENUM_VARIANT_NAMES,
466 enum_variants::STUTTER,
467 if_not_else::IF_NOT_ELSE,
468 infinite_iter::MAYBE_INFINITE_ITER,
469 items_after_statements::ITEMS_AFTER_STATEMENTS,
470 loops::EXPLICIT_INTO_ITER_LOOP,
471 loops::EXPLICIT_ITER_LOOP,
472 matches::SINGLE_MATCH_ELSE,
474 methods::MAP_FLATTEN,
475 methods::OPTION_MAP_UNWRAP_OR,
476 methods::OPTION_MAP_UNWRAP_OR_ELSE,
477 methods::RESULT_MAP_UNWRAP_OR_ELSE,
478 misc::USED_UNDERSCORE_BINDING,
479 misc_early::UNSEPARATED_LITERAL_SUFFIX,
481 needless_continue::NEEDLESS_CONTINUE,
482 non_expressive_names::SIMILAR_NAMES,
483 replace_consts::REPLACE_CONSTS,
484 shadow::SHADOW_UNRELATED,
485 strings::STRING_ADD_ASSIGN,
486 types::CAST_POSSIBLE_TRUNCATION,
487 types::CAST_POSSIBLE_WRAP,
488 types::CAST_PRECISION_LOSS,
489 types::CAST_SIGN_LOSS,
490 types::INVALID_UPCAST_COMPARISONS,
492 unicode::NON_ASCII_LITERAL,
493 unicode::UNICODE_NOT_NFC,
497 reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
498 utils::internal_lints::CLIPPY_LINTS_INTERNAL,
499 utils::internal_lints::COMPILER_LINT_FUNCTIONS,
500 utils::internal_lints::DEFAULT_HASH_TYPES,
501 utils::internal_lints::LINT_WITHOUT_LINT_PASS,
504 reg.register_lint_group("clippy::all", Some("clippy"), vec![
505 approx_const::APPROX_CONSTANT,
506 assign_ops::ASSIGN_OP_PATTERN,
507 assign_ops::MISREFACTORED_ASSIGN_OP,
508 attrs::DEPRECATED_SEMVER,
509 attrs::USELESS_ATTRIBUTE,
510 bit_mask::BAD_BIT_MASK,
511 bit_mask::INEFFECTIVE_BIT_MASK,
512 bit_mask::VERBOSE_BIT_MASK,
513 blacklisted_name::BLACKLISTED_NAME,
514 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
515 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
517 booleans::NONMINIMAL_BOOL,
518 bytecount::NAIVE_BYTECOUNT,
519 collapsible_if::COLLAPSIBLE_IF,
520 const_static_lifetime::CONST_STATIC_LIFETIME,
521 copies::IF_SAME_THEN_ELSE,
522 copies::IFS_SAME_COND,
523 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
524 derive::DERIVE_HASH_XOR_EQ,
525 double_comparison::DOUBLE_COMPARISONS,
526 double_parens::DOUBLE_PARENS,
527 drop_forget_ref::DROP_COPY,
528 drop_forget_ref::DROP_REF,
529 drop_forget_ref::FORGET_COPY,
530 drop_forget_ref::FORGET_REF,
531 duration_subsec::DURATION_SUBSEC,
533 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
534 enum_variants::ENUM_VARIANT_NAMES,
535 enum_variants::MODULE_INCEPTION,
538 erasing_op::ERASING_OP,
540 eta_reduction::REDUNDANT_CLOSURE,
541 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
542 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
543 excessive_precision::EXCESSIVE_PRECISION,
544 explicit_write::EXPLICIT_WRITE,
545 format::USELESS_FORMAT,
546 formatting::POSSIBLE_MISSING_COMMA,
547 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
548 formatting::SUSPICIOUS_ELSE_FORMATTING,
549 functions::NOT_UNSAFE_PTR_ARG_DEREF,
550 functions::TOO_MANY_ARGUMENTS,
551 identity_conversion::IDENTITY_CONVERSION,
552 identity_op::IDENTITY_OP,
553 if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
554 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
555 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
556 infinite_iter::INFINITE_ITER,
557 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
558 int_plus_one::INT_PLUS_ONE,
559 invalid_ref::INVALID_REF,
560 large_enum_variant::LARGE_ENUM_VARIANT,
561 len_zero::LEN_WITHOUT_IS_EMPTY,
563 let_if_seq::USELESS_LET_IF_SEQ,
564 lifetimes::EXTRA_UNUSED_LIFETIMES,
565 lifetimes::NEEDLESS_LIFETIMES,
566 literal_representation::INCONSISTENT_DIGIT_GROUPING,
567 literal_representation::LARGE_DIGIT_GROUPS,
568 literal_representation::MISTYPED_LITERAL_SUFFIXES,
569 literal_representation::UNREADABLE_LITERAL,
571 loops::EXPLICIT_COUNTER_LOOP,
573 loops::FOR_LOOP_OVER_OPTION,
574 loops::FOR_LOOP_OVER_RESULT,
575 loops::ITER_NEXT_LOOP,
576 loops::MANUAL_MEMCPY,
577 loops::MUT_RANGE_BOUND,
578 loops::NEEDLESS_COLLECT,
579 loops::NEEDLESS_RANGE_LOOP,
581 loops::REVERSE_RANGE_LOOP,
582 loops::UNUSED_COLLECT,
583 loops::WHILE_IMMUTABLE_CONDITION,
584 loops::WHILE_LET_LOOP,
585 loops::WHILE_LET_ON_ITERATOR,
586 map_unit_fn::OPTION_MAP_UNIT_FN,
587 map_unit_fn::RESULT_MAP_UNIT_FN,
588 matches::MATCH_AS_REF,
590 matches::MATCH_OVERLAPPING_ARM,
591 matches::MATCH_REF_PATS,
592 matches::MATCH_WILD_ERR_ARM,
593 matches::SINGLE_MATCH,
594 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
595 methods::CHARS_LAST_CMP,
596 methods::CHARS_NEXT_CMP,
597 methods::CLONE_DOUBLE_REF,
598 methods::CLONE_ON_COPY,
599 methods::EXPECT_FUN_CALL,
600 methods::FILTER_NEXT,
602 methods::ITER_CLONED_COLLECT,
604 methods::ITER_SKIP_NEXT,
605 methods::NEW_RET_NO_SELF,
607 methods::OPTION_MAP_OR_NONE,
608 methods::OR_FUN_CALL,
609 methods::SEARCH_IS_SOME,
610 methods::SHOULD_IMPLEMENT_TRAIT,
611 methods::SINGLE_CHAR_PATTERN,
612 methods::STRING_EXTEND_CHARS,
613 methods::TEMPORARY_CSTRING_AS_PTR,
614 methods::UNNECESSARY_FILTER_MAP,
615 methods::UNNECESSARY_FOLD,
616 methods::USELESS_ASREF,
617 methods::WRONG_SELF_CONVENTION,
623 misc::REDUNDANT_PATTERN,
624 misc::SHORT_CIRCUIT_STATEMENT,
625 misc::TOPLEVEL_REF_ARG,
627 misc_early::BUILTIN_TYPE_SHADOW,
628 misc_early::DOUBLE_NEG,
629 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
630 misc_early::MIXED_CASE_HEX_LITERALS,
631 misc_early::REDUNDANT_CLOSURE_CALL,
632 misc_early::UNNEEDED_FIELD_PATTERN,
633 misc_early::ZERO_PREFIXED_LITERAL,
634 mut_reference::UNNECESSARY_MUT_PASSED,
635 mutex_atomic::MUTEX_ATOMIC,
636 needless_bool::BOOL_COMPARISON,
637 needless_bool::NEEDLESS_BOOL,
638 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
639 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
640 needless_update::NEEDLESS_UPDATE,
641 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
642 neg_multiply::NEG_MULTIPLY,
643 new_without_default::NEW_WITHOUT_DEFAULT,
644 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
645 no_effect::NO_EFFECT,
646 no_effect::UNNECESSARY_OPERATION,
647 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
648 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
649 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
650 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
651 ok_if_let::IF_LET_SOME_RESULT,
652 open_options::NONSENSICAL_OPEN_OPTIONS,
653 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
654 panic_unimplemented::PANIC_PARAMS,
655 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
656 precedence::PRECEDENCE,
660 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
661 question_mark::QUESTION_MARK,
662 ranges::ITERATOR_STEP_BY_ZERO,
663 ranges::RANGE_MINUS_ONE,
664 ranges::RANGE_PLUS_ONE,
665 ranges::RANGE_ZIP_WITH_LEN,
666 redundant_field_names::REDUNDANT_FIELD_NAMES,
667 reference::DEREF_ADDROF,
668 reference::REF_IN_DEREF,
669 regex::INVALID_REGEX,
671 regex::TRIVIAL_REGEX,
672 returns::LET_AND_RETURN,
673 returns::NEEDLESS_RETURN,
674 serde_api::SERDE_API_MISUSE,
675 strings::STRING_LIT_AS_BYTES,
676 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
677 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
678 swap::ALMOST_SWAPPED,
680 temporary_assignment::TEMPORARY_ASSIGNMENT,
681 transmute::CROSSPOINTER_TRANSMUTE,
682 transmute::TRANSMUTE_BYTES_TO_STR,
683 transmute::TRANSMUTE_INT_TO_BOOL,
684 transmute::TRANSMUTE_INT_TO_CHAR,
685 transmute::TRANSMUTE_INT_TO_FLOAT,
686 transmute::TRANSMUTE_PTR_TO_PTR,
687 transmute::TRANSMUTE_PTR_TO_REF,
688 transmute::USELESS_TRANSMUTE,
689 transmute::WRONG_TRANSMUTE,
690 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
691 types::ABSURD_EXTREME_COMPARISONS,
694 types::CAST_LOSSLESS,
695 types::CAST_PTR_ALIGNMENT,
696 types::CHAR_LIT_AS_U8,
697 types::IMPLICIT_HASHER,
698 types::LET_UNIT_VALUE,
699 types::OPTION_OPTION,
700 types::TYPE_COMPLEXITY,
703 types::UNNECESSARY_CAST,
704 unicode::ZERO_WIDTH_SPACE,
705 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
706 unused_io_amount::UNUSED_IO_AMOUNT,
707 unused_label::UNUSED_LABEL,
709 write::PRINT_LITERAL,
710 write::PRINT_WITH_NEWLINE,
711 write::PRINTLN_EMPTY_STRING,
712 write::WRITE_LITERAL,
713 write::WRITE_WITH_NEWLINE,
714 write::WRITELN_EMPTY_STRING,
715 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
718 reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
719 assign_ops::ASSIGN_OP_PATTERN,
720 bit_mask::VERBOSE_BIT_MASK,
721 blacklisted_name::BLACKLISTED_NAME,
722 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
723 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
724 collapsible_if::COLLAPSIBLE_IF,
725 const_static_lifetime::CONST_STATIC_LIFETIME,
726 enum_variants::ENUM_VARIANT_NAMES,
727 enum_variants::MODULE_INCEPTION,
729 eta_reduction::REDUNDANT_CLOSURE,
730 excessive_precision::EXCESSIVE_PRECISION,
731 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
732 formatting::SUSPICIOUS_ELSE_FORMATTING,
733 if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
734 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
735 len_zero::LEN_WITHOUT_IS_EMPTY,
737 let_if_seq::USELESS_LET_IF_SEQ,
738 literal_representation::INCONSISTENT_DIGIT_GROUPING,
739 literal_representation::LARGE_DIGIT_GROUPS,
740 literal_representation::UNREADABLE_LITERAL,
743 loops::NEEDLESS_RANGE_LOOP,
744 loops::WHILE_LET_ON_ITERATOR,
746 matches::MATCH_OVERLAPPING_ARM,
747 matches::MATCH_REF_PATS,
748 matches::MATCH_WILD_ERR_ARM,
749 matches::SINGLE_MATCH,
750 mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
751 methods::CHARS_LAST_CMP,
753 methods::ITER_CLONED_COLLECT,
754 methods::ITER_SKIP_NEXT,
755 methods::NEW_RET_NO_SELF,
757 methods::OPTION_MAP_OR_NONE,
758 methods::SHOULD_IMPLEMENT_TRAIT,
759 methods::STRING_EXTEND_CHARS,
760 methods::UNNECESSARY_FOLD,
761 methods::WRONG_SELF_CONVENTION,
762 misc::REDUNDANT_PATTERN,
763 misc::TOPLEVEL_REF_ARG,
765 misc_early::BUILTIN_TYPE_SHADOW,
766 misc_early::DOUBLE_NEG,
767 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
768 misc_early::MIXED_CASE_HEX_LITERALS,
769 misc_early::UNNEEDED_FIELD_PATTERN,
770 mut_reference::UNNECESSARY_MUT_PASSED,
771 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
772 neg_multiply::NEG_MULTIPLY,
773 new_without_default::NEW_WITHOUT_DEFAULT,
774 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
775 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
776 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
777 ok_if_let::IF_LET_SOME_RESULT,
778 panic_unimplemented::PANIC_PARAMS,
781 question_mark::QUESTION_MARK,
782 redundant_field_names::REDUNDANT_FIELD_NAMES,
784 regex::TRIVIAL_REGEX,
785 returns::LET_AND_RETURN,
786 returns::NEEDLESS_RETURN,
787 strings::STRING_LIT_AS_BYTES,
788 types::IMPLICIT_HASHER,
789 types::LET_UNIT_VALUE,
790 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
791 write::PRINT_LITERAL,
792 write::PRINT_WITH_NEWLINE,
793 write::PRINTLN_EMPTY_STRING,
794 write::WRITE_LITERAL,
795 write::WRITE_WITH_NEWLINE,
796 write::WRITELN_EMPTY_STRING,
799 reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
800 assign_ops::MISREFACTORED_ASSIGN_OP,
801 booleans::NONMINIMAL_BOOL,
802 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
803 double_comparison::DOUBLE_COMPARISONS,
804 double_parens::DOUBLE_PARENS,
805 duration_subsec::DURATION_SUBSEC,
806 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
807 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
808 explicit_write::EXPLICIT_WRITE,
809 format::USELESS_FORMAT,
810 functions::TOO_MANY_ARGUMENTS,
811 identity_conversion::IDENTITY_CONVERSION,
812 identity_op::IDENTITY_OP,
813 int_plus_one::INT_PLUS_ONE,
814 lifetimes::EXTRA_UNUSED_LIFETIMES,
815 lifetimes::NEEDLESS_LIFETIMES,
816 loops::EXPLICIT_COUNTER_LOOP,
817 loops::MUT_RANGE_BOUND,
818 loops::WHILE_LET_LOOP,
819 map_unit_fn::OPTION_MAP_UNIT_FN,
820 map_unit_fn::RESULT_MAP_UNIT_FN,
821 matches::MATCH_AS_REF,
822 methods::CHARS_NEXT_CMP,
823 methods::CLONE_ON_COPY,
824 methods::FILTER_NEXT,
825 methods::SEARCH_IS_SOME,
826 methods::UNNECESSARY_FILTER_MAP,
827 methods::USELESS_ASREF,
828 misc::SHORT_CIRCUIT_STATEMENT,
829 misc_early::REDUNDANT_CLOSURE_CALL,
830 misc_early::ZERO_PREFIXED_LITERAL,
831 needless_bool::BOOL_COMPARISON,
832 needless_bool::NEEDLESS_BOOL,
833 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
834 needless_update::NEEDLESS_UPDATE,
835 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
836 no_effect::NO_EFFECT,
837 no_effect::UNNECESSARY_OPERATION,
838 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
839 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
840 precedence::PRECEDENCE,
841 ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
842 ranges::RANGE_MINUS_ONE,
843 ranges::RANGE_PLUS_ONE,
844 ranges::RANGE_ZIP_WITH_LEN,
845 reference::DEREF_ADDROF,
846 reference::REF_IN_DEREF,
848 temporary_assignment::TEMPORARY_ASSIGNMENT,
849 transmute::CROSSPOINTER_TRANSMUTE,
850 transmute::TRANSMUTE_BYTES_TO_STR,
851 transmute::TRANSMUTE_INT_TO_BOOL,
852 transmute::TRANSMUTE_INT_TO_CHAR,
853 transmute::TRANSMUTE_INT_TO_FLOAT,
854 transmute::TRANSMUTE_PTR_TO_PTR,
855 transmute::TRANSMUTE_PTR_TO_REF,
856 transmute::USELESS_TRANSMUTE,
858 types::CAST_LOSSLESS,
859 types::CHAR_LIT_AS_U8,
860 types::OPTION_OPTION,
861 types::TYPE_COMPLEXITY,
863 types::UNNECESSARY_CAST,
864 unused_label::UNUSED_LABEL,
865 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
868 reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
869 approx_const::APPROX_CONSTANT,
870 attrs::DEPRECATED_SEMVER,
871 attrs::USELESS_ATTRIBUTE,
872 bit_mask::BAD_BIT_MASK,
873 bit_mask::INEFFECTIVE_BIT_MASK,
875 copies::IF_SAME_THEN_ELSE,
876 copies::IFS_SAME_COND,
877 derive::DERIVE_HASH_XOR_EQ,
878 drop_forget_ref::DROP_COPY,
879 drop_forget_ref::DROP_REF,
880 drop_forget_ref::FORGET_COPY,
881 drop_forget_ref::FORGET_REF,
882 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
884 erasing_op::ERASING_OP,
885 formatting::POSSIBLE_MISSING_COMMA,
886 functions::NOT_UNSAFE_PTR_ARG_DEREF,
887 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
888 infinite_iter::INFINITE_ITER,
889 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
890 invalid_ref::INVALID_REF,
891 literal_representation::MISTYPED_LITERAL_SUFFIXES,
892 loops::FOR_LOOP_OVER_OPTION,
893 loops::FOR_LOOP_OVER_RESULT,
894 loops::ITER_NEXT_LOOP,
896 loops::REVERSE_RANGE_LOOP,
897 loops::WHILE_IMMUTABLE_CONDITION,
898 methods::CLONE_DOUBLE_REF,
899 methods::TEMPORARY_CSTRING_AS_PTR,
904 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
905 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
906 open_options::NONSENSICAL_OPEN_OPTIONS,
908 ranges::ITERATOR_STEP_BY_ZERO,
909 regex::INVALID_REGEX,
910 serde_api::SERDE_API_MISUSE,
911 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
912 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
913 swap::ALMOST_SWAPPED,
914 transmute::WRONG_TRANSMUTE,
915 types::ABSURD_EXTREME_COMPARISONS,
916 types::CAST_PTR_ALIGNMENT,
918 unicode::ZERO_WIDTH_SPACE,
919 unused_io_amount::UNUSED_IO_AMOUNT,
922 reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
923 bytecount::NAIVE_BYTECOUNT,
926 large_enum_variant::LARGE_ENUM_VARIANT,
927 loops::MANUAL_MEMCPY,
928 loops::NEEDLESS_COLLECT,
929 loops::UNUSED_COLLECT,
930 methods::EXPECT_FUN_CALL,
932 methods::OR_FUN_CALL,
933 methods::SINGLE_CHAR_PATTERN,
935 mutex_atomic::MUTEX_ATOMIC,
936 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
941 reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
942 multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
945 reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
946 attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
947 fallible_impl_from::FALLIBLE_IMPL_FROM,
948 mutex_atomic::MUTEX_INTEGER,
949 needless_borrow::NEEDLESS_BORROW,
950 unwrap::PANICKING_UNWRAP,
951 unwrap::UNNECESSARY_UNWRAP,
955 // only exists to let the dogfood integration test works.
956 // Don't run clippy as an executable directly
957 #[allow(dead_code, clippy::print_stdout)]
959 panic!("Please use the cargo-clippy executable");