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(macro_vis_matcher)]
9 #![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)]
10 #![recursion_limit = "256"]
11 #![allow(stable_features)]
12 #![feature(iterator_find_map)]
13 #![feature(macro_at_most_once_rep)]
14 #![feature(tool_attributes)]
15 #![warn(rust_2018_idioms)]
22 macro_rules! declare_clippy_lint {
23 { pub $name:tt, style, $description:tt } => {
24 declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
26 { pub $name:tt, correctness, $description:tt } => {
27 declare_lint! { pub $name, Deny, $description, report_in_external_macro: true }
29 { pub $name:tt, complexity, $description:tt } => {
30 declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
32 { pub $name:tt, perf, $description:tt } => {
33 declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
35 { pub $name:tt, pedantic, $description:tt } => {
36 declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
38 { pub $name:tt, restriction, $description:tt } => {
39 declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
41 { pub $name:tt, cargo, $description:tt } => {
42 declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
44 { pub $name:tt, nursery, $description:tt } => {
45 declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
47 { pub $name:tt, internal, $description:tt } => {
48 declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
50 { pub $name:tt, internal_warn, $description:tt } => {
51 declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
59 // begin lints modules, do not remove this comment, it’s used in `update_lints`
65 pub mod blacklisted_name;
66 pub mod block_in_if_condition;
69 pub mod collapsible_if;
70 pub mod const_static_lifetime;
72 pub mod cyclomatic_complexity;
73 pub mod default_trait_access;
76 pub mod double_comparison;
77 pub mod double_parens;
78 pub mod drop_forget_ref;
79 pub mod duration_subsec;
80 pub mod else_if_without_else;
84 pub mod enum_glob_use;
85 pub mod enum_variants;
89 pub mod eta_reduction;
90 pub mod eval_order_dependence;
91 pub mod excessive_precision;
92 pub mod explicit_write;
93 pub mod fallible_impl_from;
97 pub mod identity_conversion;
99 pub mod if_let_redundant_pattern_matching;
101 pub mod indexing_slicing;
102 pub mod infallible_destructuring_match;
103 pub mod infinite_iter;
104 pub mod inherent_impl;
105 pub mod inline_fn_without_body;
106 pub mod int_plus_one;
108 pub mod items_after_statements;
109 pub mod large_enum_variant;
113 pub mod literal_representation;
124 pub mod missing_inline;
125 pub mod multiple_crate_versions;
127 pub mod mut_reference;
128 pub mod mutex_atomic;
129 pub mod needless_bool;
130 pub mod needless_borrow;
131 pub mod needless_borrowed_ref;
132 pub mod needless_continue;
133 pub mod needless_pass_by_value;
134 pub mod needless_update;
135 pub mod neg_cmp_op_on_partial_ord;
136 pub mod neg_multiply;
137 pub mod new_without_default;
139 pub mod non_copy_const;
140 pub mod non_expressive_names;
142 pub mod open_options;
143 pub mod overflow_check_conditional;
144 pub mod panic_unimplemented;
145 pub mod partialeq_ne_impl;
148 pub mod question_mark;
150 pub mod redundant_field_names;
153 pub mod replace_consts;
158 pub mod suspicious_trait_impl;
160 pub mod temporary_assignment;
162 pub mod trivially_copy_pass_by_ref;
165 pub mod unsafe_removed_from_name;
166 pub mod unused_io_amount;
167 pub mod unused_label;
172 pub mod zero_div_zero;
173 // end lints modules, do not remove this comment, it’s used in `update_lints`
175 use crate::utils::conf::Conf;
178 crate use syntax::ast::{Name, NodeId};
181 pub fn register_pre_expansion_lints(session: &rustc::session::Session, store: &mut rustc::lint::LintStore, conf: &Conf) {
182 store.register_pre_expansion_pass(Some(session), box write::Pass);
183 store.register_pre_expansion_pass(Some(session), box redundant_field_names::RedundantFieldNames);
184 store.register_pre_expansion_pass(Some(session), box non_expressive_names::NonExpressiveNames {
185 single_char_binding_names_threshold: conf.single_char_binding_names_threshold,
189 pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
190 match utils::conf::file_from_args(reg.args()) {
192 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
193 // do not require the file to exist
194 let file_name = if let Some(file_name) = file_name {
197 match utils::conf::lookup_conf_file() {
200 reg.sess.struct_err(&format!("error finding Clippy's configuration file: {}", error)).emit();
206 let file_name = file_name.map(|file_name| if file_name.is_relative() {
208 .local_crate_source_file
210 .and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
217 let (conf, errors) = utils::conf::read(file_name.as_ref().map(|p| p.as_ref()));
219 // all conf errors are non-fatal, we just use the default conf in case of error
220 for error in errors {
221 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();
226 Err((err, span)) => {
227 reg.sess.struct_span_err(span, err)
228 .span_note(span, "Clippy will use default configuration")
230 toml::from_str("").expect("we never error on empty config files")
236 pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
237 let mut store = reg.sess.lint_store.borrow_mut();
238 store.register_removed(
240 "`assert!()` will be more flexible with RFC 2011",
242 store.register_removed(
244 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
246 store.register_removed(
247 "range_step_by_zero",
248 "`iterator.step_by(0)` panics nowadays",
250 store.register_removed(
252 "`Vec::as_slice` has been stabilized in 1.7",
254 store.register_removed(
255 "unstable_as_mut_slice",
256 "`Vec::as_mut_slice` has been stabilized in 1.7",
258 store.register_removed(
260 "using `str::to_string` is common even today and specialization will likely happen soon",
262 store.register_removed(
264 "using `string::to_string` is common even today and specialization will likely happen soon",
266 store.register_removed(
267 "misaligned_transmute",
268 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
270 // end deprecated lints, do not remove this comment, it’s used in `update_lints`
272 reg.register_late_lint_pass(box serde_api::Serde);
273 reg.register_early_lint_pass(box utils::internal_lints::Clippy);
274 reg.register_late_lint_pass(box utils::internal_lints::LintWithoutLintPass::default());
275 reg.register_early_lint_pass(box utils::internal_lints::DefaultHashTypes::default());
276 reg.register_late_lint_pass(box utils::inspector::Pass);
277 reg.register_late_lint_pass(box utils::author::Pass);
278 reg.register_late_lint_pass(box types::TypePass);
279 reg.register_late_lint_pass(box booleans::NonminimalBool);
280 reg.register_late_lint_pass(box eq_op::EqOp);
281 reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
282 reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
283 reg.register_late_lint_pass(box enum_clike::UnportableVariant);
284 reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
285 reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
286 reg.register_late_lint_pass(box ptr::PointerPass);
287 reg.register_late_lint_pass(box needless_bool::NeedlessBool);
288 reg.register_late_lint_pass(box needless_bool::BoolComparison);
289 reg.register_late_lint_pass(box approx_const::Pass);
290 reg.register_late_lint_pass(box misc::Pass);
291 reg.register_early_lint_pass(box precedence::Precedence);
292 reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
293 reg.register_late_lint_pass(box eta_reduction::EtaPass);
294 reg.register_late_lint_pass(box identity_op::IdentityOp);
295 reg.register_late_lint_pass(box erasing_op::ErasingOp);
296 reg.register_early_lint_pass(box items_after_statements::ItemsAfterStatements);
297 reg.register_late_lint_pass(box mut_mut::MutMut);
298 reg.register_late_lint_pass(box mut_reference::UnnecessaryMutPassed);
299 reg.register_late_lint_pass(box len_zero::LenZero);
300 reg.register_late_lint_pass(box attrs::AttrPass);
301 reg.register_early_lint_pass(box collapsible_if::CollapsibleIf);
302 reg.register_late_lint_pass(box block_in_if_condition::BlockInIfCondition);
303 reg.register_late_lint_pass(box unicode::Unicode);
304 reg.register_late_lint_pass(box strings::StringAdd);
305 reg.register_early_lint_pass(box returns::ReturnPass);
306 reg.register_late_lint_pass(box methods::Pass);
307 reg.register_late_lint_pass(box shadow::Pass);
308 reg.register_late_lint_pass(box types::LetPass);
309 reg.register_late_lint_pass(box types::UnitCmp);
310 reg.register_late_lint_pass(box loops::Pass);
311 reg.register_late_lint_pass(box lifetimes::LifetimePass);
312 reg.register_late_lint_pass(box entry::HashMapLint);
313 reg.register_late_lint_pass(box ranges::Pass);
314 reg.register_late_lint_pass(box types::CastPass);
315 reg.register_late_lint_pass(box types::TypeComplexityPass::new(conf.type_complexity_threshold));
316 reg.register_late_lint_pass(box matches::MatchPass);
317 reg.register_late_lint_pass(box minmax::MinMaxPass);
318 reg.register_late_lint_pass(box open_options::NonSensical);
319 reg.register_late_lint_pass(box zero_div_zero::Pass);
320 reg.register_late_lint_pass(box mutex_atomic::MutexAtomic);
321 reg.register_late_lint_pass(box needless_update::Pass);
322 reg.register_late_lint_pass(box needless_borrow::NeedlessBorrow);
323 reg.register_late_lint_pass(box needless_borrowed_ref::NeedlessBorrowedRef);
324 reg.register_late_lint_pass(box no_effect::Pass);
325 reg.register_late_lint_pass(box map_clone::Pass);
326 reg.register_late_lint_pass(box temporary_assignment::Pass);
327 reg.register_late_lint_pass(box transmute::Transmute);
328 reg.register_late_lint_pass(
329 box cyclomatic_complexity::CyclomaticComplexity::new(conf.cyclomatic_complexity_threshold)
331 reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
332 reg.register_early_lint_pass(box misc_early::MiscEarly);
333 reg.register_late_lint_pass(box panic_unimplemented::Pass);
334 reg.register_late_lint_pass(box strings::StringLitAsBytes);
335 reg.register_late_lint_pass(box derive::Derive);
336 reg.register_late_lint_pass(box types::CharLitAsU8);
337 reg.register_late_lint_pass(box vec::Pass);
338 reg.register_late_lint_pass(box drop_forget_ref::Pass);
339 reg.register_late_lint_pass(box empty_enum::EmptyEnum);
340 reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
341 reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
342 reg.register_late_lint_pass(box regex::Pass::default());
343 reg.register_late_lint_pass(box copies::CopyAndPaste);
344 reg.register_late_lint_pass(box format::Pass);
345 reg.register_early_lint_pass(box formatting::Formatting);
346 reg.register_late_lint_pass(box swap::Swap);
347 reg.register_early_lint_pass(box if_not_else::IfNotElse);
348 reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
349 reg.register_early_lint_pass(box int_plus_one::IntPlusOne);
350 reg.register_late_lint_pass(box overflow_check_conditional::OverflowCheckConditional);
351 reg.register_late_lint_pass(box unused_label::UnusedLabel);
352 reg.register_late_lint_pass(box new_without_default::NewWithoutDefault);
353 reg.register_late_lint_pass(box blacklisted_name::BlackListedName::new(conf.blacklisted_names.clone()));
354 reg.register_late_lint_pass(box functions::Functions::new(conf.too_many_arguments_threshold));
355 reg.register_early_lint_pass(box doc::Doc::new(conf.doc_valid_idents.clone()));
356 reg.register_late_lint_pass(box neg_multiply::NegMultiply);
357 reg.register_early_lint_pass(box unsafe_removed_from_name::UnsafeNameRemoval);
358 reg.register_late_lint_pass(box mem_forget::MemForget);
359 reg.register_late_lint_pass(box arithmetic::Arithmetic::default());
360 reg.register_late_lint_pass(box assign_ops::AssignOps);
361 reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
362 reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
363 reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
364 reg.register_late_lint_pass(box missing_inline::MissingInline);
365 reg.register_late_lint_pass(box ok_if_let::Pass);
366 reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
367 reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
368 reg.register_early_lint_pass(box reference::Pass);
369 reg.register_early_lint_pass(box reference::DerefPass);
370 reg.register_early_lint_pass(box double_parens::DoubleParens);
371 reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
372 reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
373 reg.register_late_lint_pass(box explicit_write::Pass);
374 reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
376 let target = ®.sess.target;
377 reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
378 conf.trivial_copy_size_limit,
381 reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
382 reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
383 conf.literal_representation_threshold
385 reg.register_late_lint_pass(box use_self::UseSelf);
386 reg.register_late_lint_pass(box bytecount::ByteCount);
387 reg.register_late_lint_pass(box infinite_iter::Pass);
388 reg.register_late_lint_pass(box inline_fn_without_body::Pass);
389 reg.register_late_lint_pass(box invalid_ref::InvalidRef);
390 reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
391 reg.register_late_lint_pass(box types::ImplicitHasher);
392 reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
393 reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
394 reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
395 reg.register_late_lint_pass(box types::UnitArg);
396 reg.register_late_lint_pass(box double_comparison::DoubleComparisonPass);
397 reg.register_late_lint_pass(box question_mark::QuestionMarkPass);
398 reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
399 reg.register_early_lint_pass(box multiple_crate_versions::Pass);
400 reg.register_late_lint_pass(box map_unit_fn::Pass);
401 reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
402 reg.register_late_lint_pass(box inherent_impl::Pass::default());
403 reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
404 reg.register_late_lint_pass(box unwrap::Pass);
405 reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
406 reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
407 reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
408 reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
410 reg.register_lint_group("clippy_restriction", vec![
411 arithmetic::FLOAT_ARITHMETIC,
412 arithmetic::INTEGER_ARITHMETIC,
413 assign_ops::ASSIGN_OPS,
414 else_if_without_else::ELSE_IF_WITHOUT_ELSE,
415 indexing_slicing::INDEXING_SLICING,
416 inherent_impl::MULTIPLE_INHERENT_IMPL,
417 literal_representation::DECIMAL_LITERAL_REPRESENTATION,
418 mem_forget::MEM_FORGET,
419 methods::CLONE_ON_REF_PTR,
420 methods::OPTION_UNWRAP_USED,
421 methods::RESULT_UNWRAP_USED,
422 methods::WRONG_PUB_SELF_CONVENTION,
423 misc::FLOAT_CMP_CONST,
424 missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
425 missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
426 panic_unimplemented::UNIMPLEMENTED,
427 shadow::SHADOW_REUSE,
434 reg.register_lint_group("clippy_pedantic", vec![
435 attrs::INLINE_ALWAYS,
436 copies::MATCH_SAME_ARMS,
437 default_trait_access::DEFAULT_TRAIT_ACCESS,
438 derive::EXPL_IMPL_CLONE_ON_COPY,
440 empty_enum::EMPTY_ENUM,
441 enum_glob_use::ENUM_GLOB_USE,
442 enum_variants::PUB_ENUM_VARIANT_NAMES,
443 enum_variants::STUTTER,
444 if_not_else::IF_NOT_ELSE,
445 infinite_iter::MAYBE_INFINITE_ITER,
446 items_after_statements::ITEMS_AFTER_STATEMENTS,
447 matches::SINGLE_MATCH_ELSE,
449 methods::OPTION_MAP_UNWRAP_OR,
450 methods::OPTION_MAP_UNWRAP_OR_ELSE,
451 methods::RESULT_MAP_UNWRAP_OR_ELSE,
452 misc::USED_UNDERSCORE_BINDING,
453 misc_early::UNSEPARATED_LITERAL_SUFFIX,
455 needless_continue::NEEDLESS_CONTINUE,
456 non_expressive_names::SIMILAR_NAMES,
457 replace_consts::REPLACE_CONSTS,
458 shadow::SHADOW_UNRELATED,
459 strings::STRING_ADD_ASSIGN,
460 types::CAST_POSSIBLE_TRUNCATION,
461 types::CAST_POSSIBLE_WRAP,
462 types::CAST_PRECISION_LOSS,
463 types::CAST_SIGN_LOSS,
464 types::INVALID_UPCAST_COMPARISONS,
466 unicode::NON_ASCII_LITERAL,
467 unicode::UNICODE_NOT_NFC,
471 reg.register_lint_group("clippy_internal", vec![
472 utils::internal_lints::CLIPPY_LINTS_INTERNAL,
473 utils::internal_lints::LINT_WITHOUT_LINT_PASS,
474 utils::internal_lints::DEFAULT_HASH_TYPES,
477 reg.register_lint_group("clippy", vec![
478 approx_const::APPROX_CONSTANT,
479 assign_ops::ASSIGN_OP_PATTERN,
480 assign_ops::MISREFACTORED_ASSIGN_OP,
481 attrs::DEPRECATED_SEMVER,
482 attrs::USELESS_ATTRIBUTE,
483 bit_mask::BAD_BIT_MASK,
484 bit_mask::INEFFECTIVE_BIT_MASK,
485 bit_mask::VERBOSE_BIT_MASK,
486 blacklisted_name::BLACKLISTED_NAME,
487 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
488 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
490 booleans::NONMINIMAL_BOOL,
491 bytecount::NAIVE_BYTECOUNT,
492 collapsible_if::COLLAPSIBLE_IF,
493 const_static_lifetime::CONST_STATIC_LIFETIME,
494 copies::IF_SAME_THEN_ELSE,
495 copies::IFS_SAME_COND,
496 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
497 derive::DERIVE_HASH_XOR_EQ,
498 double_comparison::DOUBLE_COMPARISONS,
499 double_parens::DOUBLE_PARENS,
500 drop_forget_ref::DROP_COPY,
501 drop_forget_ref::DROP_REF,
502 drop_forget_ref::FORGET_COPY,
503 drop_forget_ref::FORGET_REF,
504 duration_subsec::DURATION_SUBSEC,
506 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
507 enum_variants::ENUM_VARIANT_NAMES,
508 enum_variants::MODULE_INCEPTION,
511 erasing_op::ERASING_OP,
513 eta_reduction::REDUNDANT_CLOSURE,
514 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
515 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
516 excessive_precision::EXCESSIVE_PRECISION,
517 explicit_write::EXPLICIT_WRITE,
518 format::USELESS_FORMAT,
519 formatting::POSSIBLE_MISSING_COMMA,
520 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
521 formatting::SUSPICIOUS_ELSE_FORMATTING,
522 functions::NOT_UNSAFE_PTR_ARG_DEREF,
523 functions::TOO_MANY_ARGUMENTS,
524 identity_conversion::IDENTITY_CONVERSION,
525 identity_op::IDENTITY_OP,
526 if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
527 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
528 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
529 infinite_iter::INFINITE_ITER,
530 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
531 int_plus_one::INT_PLUS_ONE,
532 invalid_ref::INVALID_REF,
533 large_enum_variant::LARGE_ENUM_VARIANT,
534 len_zero::LEN_WITHOUT_IS_EMPTY,
536 let_if_seq::USELESS_LET_IF_SEQ,
537 lifetimes::EXTRA_UNUSED_LIFETIMES,
538 lifetimes::NEEDLESS_LIFETIMES,
539 literal_representation::INCONSISTENT_DIGIT_GROUPING,
540 literal_representation::LARGE_DIGIT_GROUPS,
541 literal_representation::UNREADABLE_LITERAL,
543 loops::EXPLICIT_COUNTER_LOOP,
544 loops::EXPLICIT_INTO_ITER_LOOP,
545 loops::EXPLICIT_ITER_LOOP,
547 loops::FOR_LOOP_OVER_OPTION,
548 loops::FOR_LOOP_OVER_RESULT,
549 loops::ITER_NEXT_LOOP,
550 loops::MANUAL_MEMCPY,
551 loops::MUT_RANGE_BOUND,
552 loops::NEEDLESS_RANGE_LOOP,
554 loops::REVERSE_RANGE_LOOP,
555 loops::UNUSED_COLLECT,
556 loops::WHILE_IMMUTABLE_CONDITION,
557 loops::WHILE_LET_LOOP,
558 loops::WHILE_LET_ON_ITERATOR,
559 map_clone::MAP_CLONE,
560 map_unit_fn::OPTION_MAP_UNIT_FN,
561 map_unit_fn::RESULT_MAP_UNIT_FN,
562 matches::MATCH_AS_REF,
564 matches::MATCH_OVERLAPPING_ARM,
565 matches::MATCH_REF_PATS,
566 matches::MATCH_WILD_ERR_ARM,
567 matches::SINGLE_MATCH,
568 methods::CHARS_LAST_CMP,
569 methods::CHARS_NEXT_CMP,
570 methods::CLONE_DOUBLE_REF,
571 methods::CLONE_ON_COPY,
572 methods::EXPECT_FUN_CALL,
573 methods::FILTER_NEXT,
575 methods::ITER_CLONED_COLLECT,
577 methods::ITER_SKIP_NEXT,
578 methods::NEW_RET_NO_SELF,
580 methods::OPTION_MAP_OR_NONE,
581 methods::OR_FUN_CALL,
582 methods::SEARCH_IS_SOME,
583 methods::SHOULD_IMPLEMENT_TRAIT,
584 methods::SINGLE_CHAR_PATTERN,
585 methods::STRING_EXTEND_CHARS,
586 methods::TEMPORARY_CSTRING_AS_PTR,
587 methods::UNNECESSARY_FOLD,
588 methods::USELESS_ASREF,
589 methods::WRONG_SELF_CONVENTION,
595 misc::REDUNDANT_PATTERN,
596 misc::SHORT_CIRCUIT_STATEMENT,
597 misc::TOPLEVEL_REF_ARG,
599 misc_early::BUILTIN_TYPE_SHADOW,
600 misc_early::DOUBLE_NEG,
601 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
602 misc_early::MIXED_CASE_HEX_LITERALS,
603 misc_early::REDUNDANT_CLOSURE_CALL,
604 misc_early::UNNEEDED_FIELD_PATTERN,
605 misc_early::ZERO_PREFIXED_LITERAL,
606 mut_reference::UNNECESSARY_MUT_PASSED,
607 mutex_atomic::MUTEX_ATOMIC,
608 needless_bool::BOOL_COMPARISON,
609 needless_bool::NEEDLESS_BOOL,
610 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
611 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
612 needless_update::NEEDLESS_UPDATE,
613 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
614 neg_multiply::NEG_MULTIPLY,
615 new_without_default::NEW_WITHOUT_DEFAULT,
616 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
617 no_effect::NO_EFFECT,
618 no_effect::UNNECESSARY_OPERATION,
619 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
620 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
621 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
622 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
623 ok_if_let::IF_LET_SOME_RESULT,
624 open_options::NONSENSICAL_OPEN_OPTIONS,
625 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
626 panic_unimplemented::PANIC_PARAMS,
627 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
628 precedence::PRECEDENCE,
632 question_mark::QUESTION_MARK,
633 ranges::ITERATOR_STEP_BY_ZERO,
634 ranges::RANGE_MINUS_ONE,
635 ranges::RANGE_ZIP_WITH_LEN,
636 redundant_field_names::REDUNDANT_FIELD_NAMES,
637 reference::DEREF_ADDROF,
638 reference::REF_IN_DEREF,
639 regex::INVALID_REGEX,
641 regex::TRIVIAL_REGEX,
642 returns::LET_AND_RETURN,
643 returns::NEEDLESS_RETURN,
644 serde_api::SERDE_API_MISUSE,
645 strings::STRING_LIT_AS_BYTES,
646 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
647 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
648 swap::ALMOST_SWAPPED,
650 temporary_assignment::TEMPORARY_ASSIGNMENT,
651 transmute::CROSSPOINTER_TRANSMUTE,
652 transmute::TRANSMUTE_BYTES_TO_STR,
653 transmute::TRANSMUTE_INT_TO_BOOL,
654 transmute::TRANSMUTE_INT_TO_CHAR,
655 transmute::TRANSMUTE_INT_TO_FLOAT,
656 transmute::TRANSMUTE_PTR_TO_PTR,
657 transmute::TRANSMUTE_PTR_TO_REF,
658 transmute::USELESS_TRANSMUTE,
659 transmute::WRONG_TRANSMUTE,
660 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
661 types::ABSURD_EXTREME_COMPARISONS,
664 types::CAST_LOSSLESS,
665 types::CAST_PTR_ALIGNMENT,
666 types::CHAR_LIT_AS_U8,
667 types::FN_TO_NUMERIC_CAST,
668 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
669 types::IMPLICIT_HASHER,
670 types::LET_UNIT_VALUE,
671 types::OPTION_OPTION,
672 types::TYPE_COMPLEXITY,
675 types::UNNECESSARY_CAST,
676 unicode::ZERO_WIDTH_SPACE,
677 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
678 unused_io_amount::UNUSED_IO_AMOUNT,
679 unused_label::UNUSED_LABEL,
681 write::PRINT_LITERAL,
682 write::PRINT_WITH_NEWLINE,
683 write::PRINTLN_EMPTY_STRING,
684 write::WRITE_LITERAL,
685 write::WRITE_WITH_NEWLINE,
686 write::WRITELN_EMPTY_STRING,
687 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
690 reg.register_lint_group("clippy_style", vec![
691 assign_ops::ASSIGN_OP_PATTERN,
692 bit_mask::VERBOSE_BIT_MASK,
693 blacklisted_name::BLACKLISTED_NAME,
694 block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
695 block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
696 collapsible_if::COLLAPSIBLE_IF,
697 const_static_lifetime::CONST_STATIC_LIFETIME,
698 enum_variants::ENUM_VARIANT_NAMES,
699 enum_variants::MODULE_INCEPTION,
701 eta_reduction::REDUNDANT_CLOSURE,
702 excessive_precision::EXCESSIVE_PRECISION,
703 formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
704 formatting::SUSPICIOUS_ELSE_FORMATTING,
705 if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
706 infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
707 len_zero::LEN_WITHOUT_IS_EMPTY,
709 let_if_seq::USELESS_LET_IF_SEQ,
710 literal_representation::INCONSISTENT_DIGIT_GROUPING,
711 literal_representation::LARGE_DIGIT_GROUPS,
712 literal_representation::UNREADABLE_LITERAL,
714 loops::EXPLICIT_INTO_ITER_LOOP,
715 loops::EXPLICIT_ITER_LOOP,
717 loops::NEEDLESS_RANGE_LOOP,
718 loops::WHILE_LET_ON_ITERATOR,
719 map_clone::MAP_CLONE,
721 matches::MATCH_OVERLAPPING_ARM,
722 matches::MATCH_REF_PATS,
723 matches::MATCH_WILD_ERR_ARM,
724 matches::SINGLE_MATCH,
725 methods::CHARS_LAST_CMP,
727 methods::ITER_CLONED_COLLECT,
728 methods::ITER_SKIP_NEXT,
729 methods::NEW_RET_NO_SELF,
731 methods::OPTION_MAP_OR_NONE,
732 methods::SHOULD_IMPLEMENT_TRAIT,
733 methods::STRING_EXTEND_CHARS,
734 methods::UNNECESSARY_FOLD,
735 methods::WRONG_SELF_CONVENTION,
736 misc::REDUNDANT_PATTERN,
737 misc::TOPLEVEL_REF_ARG,
739 misc_early::BUILTIN_TYPE_SHADOW,
740 misc_early::DOUBLE_NEG,
741 misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
742 misc_early::MIXED_CASE_HEX_LITERALS,
743 misc_early::UNNEEDED_FIELD_PATTERN,
744 mut_reference::UNNECESSARY_MUT_PASSED,
745 needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
746 neg_multiply::NEG_MULTIPLY,
747 new_without_default::NEW_WITHOUT_DEFAULT,
748 new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
749 non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
750 non_expressive_names::MANY_SINGLE_CHAR_NAMES,
751 ok_if_let::IF_LET_SOME_RESULT,
752 panic_unimplemented::PANIC_PARAMS,
755 question_mark::QUESTION_MARK,
756 ranges::RANGE_MINUS_ONE,
757 redundant_field_names::REDUNDANT_FIELD_NAMES,
759 regex::TRIVIAL_REGEX,
760 returns::LET_AND_RETURN,
761 returns::NEEDLESS_RETURN,
762 strings::STRING_LIT_AS_BYTES,
763 types::FN_TO_NUMERIC_CAST,
764 types::IMPLICIT_HASHER,
765 types::LET_UNIT_VALUE,
766 unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
767 write::PRINT_LITERAL,
768 write::PRINT_WITH_NEWLINE,
769 write::PRINTLN_EMPTY_STRING,
770 write::WRITE_LITERAL,
771 write::WRITE_WITH_NEWLINE,
772 write::WRITELN_EMPTY_STRING,
775 reg.register_lint_group("clippy_complexity", vec![
776 assign_ops::MISREFACTORED_ASSIGN_OP,
777 booleans::NONMINIMAL_BOOL,
778 cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
779 double_comparison::DOUBLE_COMPARISONS,
780 double_parens::DOUBLE_PARENS,
781 duration_subsec::DURATION_SUBSEC,
782 eval_order_dependence::DIVERGING_SUB_EXPRESSION,
783 eval_order_dependence::EVAL_ORDER_DEPENDENCE,
784 explicit_write::EXPLICIT_WRITE,
785 format::USELESS_FORMAT,
786 functions::TOO_MANY_ARGUMENTS,
787 identity_conversion::IDENTITY_CONVERSION,
788 identity_op::IDENTITY_OP,
789 int_plus_one::INT_PLUS_ONE,
790 lifetimes::EXTRA_UNUSED_LIFETIMES,
791 lifetimes::NEEDLESS_LIFETIMES,
792 loops::EXPLICIT_COUNTER_LOOP,
793 loops::MUT_RANGE_BOUND,
794 loops::WHILE_LET_LOOP,
795 map_unit_fn::OPTION_MAP_UNIT_FN,
796 map_unit_fn::RESULT_MAP_UNIT_FN,
797 matches::MATCH_AS_REF,
798 methods::CHARS_NEXT_CMP,
799 methods::CLONE_ON_COPY,
800 methods::FILTER_NEXT,
801 methods::SEARCH_IS_SOME,
802 methods::USELESS_ASREF,
803 misc::SHORT_CIRCUIT_STATEMENT,
804 misc_early::REDUNDANT_CLOSURE_CALL,
805 misc_early::ZERO_PREFIXED_LITERAL,
806 needless_bool::BOOL_COMPARISON,
807 needless_bool::NEEDLESS_BOOL,
808 needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
809 needless_update::NEEDLESS_UPDATE,
810 neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
811 no_effect::NO_EFFECT,
812 no_effect::UNNECESSARY_OPERATION,
813 overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
814 partialeq_ne_impl::PARTIALEQ_NE_IMPL,
815 precedence::PRECEDENCE,
816 ranges::RANGE_ZIP_WITH_LEN,
817 reference::DEREF_ADDROF,
818 reference::REF_IN_DEREF,
820 temporary_assignment::TEMPORARY_ASSIGNMENT,
821 transmute::CROSSPOINTER_TRANSMUTE,
822 transmute::TRANSMUTE_BYTES_TO_STR,
823 transmute::TRANSMUTE_INT_TO_BOOL,
824 transmute::TRANSMUTE_INT_TO_CHAR,
825 transmute::TRANSMUTE_INT_TO_FLOAT,
826 transmute::TRANSMUTE_PTR_TO_PTR,
827 transmute::TRANSMUTE_PTR_TO_REF,
828 transmute::USELESS_TRANSMUTE,
830 types::CAST_LOSSLESS,
831 types::CHAR_LIT_AS_U8,
832 types::OPTION_OPTION,
833 types::TYPE_COMPLEXITY,
835 types::UNNECESSARY_CAST,
836 unused_label::UNUSED_LABEL,
837 zero_div_zero::ZERO_DIVIDED_BY_ZERO,
840 reg.register_lint_group("clippy_correctness", vec![
841 approx_const::APPROX_CONSTANT,
842 attrs::DEPRECATED_SEMVER,
843 attrs::USELESS_ATTRIBUTE,
844 bit_mask::BAD_BIT_MASK,
845 bit_mask::INEFFECTIVE_BIT_MASK,
847 copies::IF_SAME_THEN_ELSE,
848 copies::IFS_SAME_COND,
849 derive::DERIVE_HASH_XOR_EQ,
850 drop_forget_ref::DROP_COPY,
851 drop_forget_ref::DROP_REF,
852 drop_forget_ref::FORGET_COPY,
853 drop_forget_ref::FORGET_REF,
854 enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
856 erasing_op::ERASING_OP,
857 formatting::POSSIBLE_MISSING_COMMA,
858 functions::NOT_UNSAFE_PTR_ARG_DEREF,
859 indexing_slicing::OUT_OF_BOUNDS_INDEXING,
860 infinite_iter::INFINITE_ITER,
861 inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
862 invalid_ref::INVALID_REF,
863 loops::FOR_LOOP_OVER_OPTION,
864 loops::FOR_LOOP_OVER_RESULT,
865 loops::ITER_NEXT_LOOP,
867 loops::REVERSE_RANGE_LOOP,
868 loops::WHILE_IMMUTABLE_CONDITION,
869 methods::CLONE_DOUBLE_REF,
870 methods::TEMPORARY_CSTRING_AS_PTR,
875 non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
876 non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
877 open_options::NONSENSICAL_OPEN_OPTIONS,
879 ranges::ITERATOR_STEP_BY_ZERO,
880 regex::INVALID_REGEX,
881 serde_api::SERDE_API_MISUSE,
882 suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
883 suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
884 swap::ALMOST_SWAPPED,
885 transmute::WRONG_TRANSMUTE,
886 types::ABSURD_EXTREME_COMPARISONS,
887 types::CAST_PTR_ALIGNMENT,
888 types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
890 unicode::ZERO_WIDTH_SPACE,
891 unused_io_amount::UNUSED_IO_AMOUNT,
894 reg.register_lint_group("clippy_perf", vec![
895 bytecount::NAIVE_BYTECOUNT,
898 large_enum_variant::LARGE_ENUM_VARIANT,
899 loops::MANUAL_MEMCPY,
900 loops::UNUSED_COLLECT,
901 methods::EXPECT_FUN_CALL,
903 methods::OR_FUN_CALL,
904 methods::SINGLE_CHAR_PATTERN,
906 mutex_atomic::MUTEX_ATOMIC,
907 trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
912 reg.register_lint_group("clippy_cargo", vec![
913 multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
916 reg.register_lint_group("clippy_nursery", vec![
917 attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
918 fallible_impl_from::FALLIBLE_IMPL_FROM,
919 mutex_atomic::MUTEX_INTEGER,
920 needless_borrow::NEEDLESS_BORROW,
921 ranges::RANGE_PLUS_ONE,
922 unwrap::PANICKING_UNWRAP,
923 unwrap::UNNECESSARY_UNWRAP,
927 // only exists to let the dogfood integration test works.
928 // Don't run clippy as an executable directly
929 #[allow(dead_code, print_stdout)]
931 panic!("Please use the cargo-clippy executable");