1 //! This file is managed by `cargo dev update_lints`. Do not edit.
3 use lazy_static::lazy_static;
8 pub use lint::LINT_LEVELS;
11 // begin lint list, do not remove this comment, it’s used in `update_lints`
12 pub static ref ALL_LINTS: Vec<Lint> = vec![
14 name: "absurd_extreme_comparisons",
16 desc: "a comparison with a maximum or minimum value that is always true or false",
21 name: "almost_swapped",
23 desc: "`foo = bar; bar = foo` sequence",
28 name: "approx_constant",
30 desc: "the approximate of a known float constant (in `std::fXX::consts`)",
32 module: "approx_const",
35 name: "as_conversions",
37 desc: "using a potentially dangerous silent `as` conversion",
39 module: "as_conversions",
42 name: "assertions_on_constants",
44 desc: "`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`",
46 module: "assertions_on_constants",
49 name: "assign_op_pattern",
51 desc: "assigning the result of an operation on a variable to that same variable",
56 name: "await_holding_lock",
58 desc: "Inside an async function, holding a MutexGuard while calling await",
60 module: "await_holding_lock",
65 desc: "expressions of the form `_ & mask == select` that will only ever return `true` or `false`",
70 name: "bind_instead_of_map",
72 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
77 name: "blacklisted_name",
79 desc: "usage of a blacklisted/placeholder name",
81 module: "blacklisted_name",
84 name: "blocks_in_if_conditions",
86 desc: "useless or complex blocks that can be eliminated in conditions",
88 module: "blocks_in_if_conditions",
91 name: "bool_comparison",
93 desc: "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`",
95 module: "needless_bool",
98 name: "borrow_interior_mutable_const",
100 desc: "referencing `const` with interior mutability",
102 module: "non_copy_const",
105 name: "borrowed_box",
107 desc: "a borrow of a boxed type",
114 desc: "usage of `Box<Vec<T>>`, vector elements are already on the heap",
121 desc: "using `Box<T>` where unnecessary",
126 name: "builtin_type_shadow",
128 desc: "shadowing a builtin type",
130 module: "misc_early",
133 name: "cargo_common_metadata",
135 desc: "common metadata is defined in `Cargo.toml`",
137 module: "cargo_common_metadata",
140 name: "cast_lossless",
142 desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
147 name: "cast_possible_truncation",
149 desc: "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`",
154 name: "cast_possible_wrap",
156 desc: "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`",
161 name: "cast_precision_loss",
163 desc: "casts that cause loss of precision, e.g., `x as f32` where `x: u64`",
168 name: "cast_ptr_alignment",
170 desc: "cast from a pointer to a more-strictly-aligned pointer",
175 name: "cast_ref_to_mut",
176 group: "correctness",
177 desc: "a cast of reference to a mutable pointer",
182 name: "cast_sign_loss",
184 desc: "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`",
189 name: "char_lit_as_u8",
191 desc: "casting a character literal to `u8` truncates",
196 name: "chars_last_cmp",
198 desc: "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char",
203 name: "chars_next_cmp",
205 desc: "using `.chars().next()` to check if a string starts with a char",
210 name: "checked_conversions",
212 desc: "`try_from` could replace manual bounds checking when casting",
214 module: "checked_conversions",
217 name: "clone_double_ref",
218 group: "correctness",
219 desc: "using `clone` on `&&T`",
224 name: "clone_on_copy",
226 desc: "using `clone` on a `Copy` type",
231 name: "clone_on_ref_ptr",
232 group: "restriction",
233 desc: "using \'clone\' on a ref-counted pointer",
239 group: "correctness",
240 desc: "comparisons to `NAN`, which will always return false, probably not intended",
247 desc: "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead.",
254 desc: "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`",
259 name: "cognitive_complexity",
261 desc: "functions that should be split up into multiple functions",
263 module: "cognitive_complexity",
266 name: "collapsible_if",
268 desc: "`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)",
270 module: "collapsible_if",
273 name: "comparison_chain",
275 desc: "`if`s that can be rewritten with `match` and `cmp`",
277 module: "comparison_chain",
280 name: "copy_iterator",
282 desc: "implementing `Iterator` on a `Copy` type",
284 module: "copy_iterator",
287 name: "crosspointer_transmute",
289 desc: "transmutes that have to or from types that are a pointer to the other",
295 group: "restriction",
296 desc: "`dbg!` macro is intended as a debugging tool",
301 name: "debug_assert_with_mut_call",
303 desc: "mutable arguments in `debug_assert{,_ne,_eq}!`",
305 module: "mutable_debug_assertion",
308 name: "decimal_literal_representation",
309 group: "restriction",
310 desc: "using decimal representation when hexadecimal would be better",
312 module: "literal_representation",
315 name: "declare_interior_mutable_const",
316 group: "correctness",
317 desc: "declaring `const` with interior mutability",
319 module: "non_copy_const",
322 name: "default_trait_access",
324 desc: "checks for literal calls to `Default::default()`",
326 module: "default_trait_access",
329 name: "deprecated_cfg_attr",
331 desc: "usage of `cfg_attr(rustfmt)` instead of tool attributes",
336 name: "deprecated_semver",
337 group: "correctness",
338 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
343 name: "deref_addrof",
345 desc: "use of `*&` or `*&mut` in an expression",
350 name: "derive_hash_xor_eq",
351 group: "correctness",
352 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
357 name: "diverging_sub_expression",
359 desc: "whether an expression contains a diverging sub expression",
361 module: "eval_order_dependence",
364 name: "doc_markdown",
366 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
371 name: "double_comparisons",
373 desc: "unnecessary double comparisons that can be simplified",
375 module: "double_comparison",
378 name: "double_must_use",
380 desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method",
387 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
389 module: "misc_early",
392 name: "double_parens",
394 desc: "Warn on unnecessary double parentheses",
396 module: "double_parens",
400 group: "correctness",
401 desc: "Bounds of the form `T: Drop` are useless",
403 module: "drop_bounds",
407 group: "correctness",
408 desc: "calls to `std::mem::drop` with a value that implements Copy",
410 module: "drop_forget_ref",
414 group: "correctness",
415 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
417 module: "drop_forget_ref",
420 name: "duplicate_underscore_argument",
422 desc: "function arguments having names which only differ by an underscore",
424 module: "misc_early",
427 name: "duration_subsec",
429 desc: "checks for calculation of subsecond microseconds or milliseconds",
431 module: "duration_subsec",
434 name: "else_if_without_else",
435 group: "restriction",
436 desc: "`if` expression with an `else if`, but without a final `else` branch",
438 module: "else_if_without_else",
443 desc: "enum with no variants",
445 module: "empty_enum",
448 name: "empty_line_after_outer_attr",
450 desc: "empty line after outer attribute",
457 desc: "empty `loop {}`, which should block or sleep",
462 name: "enum_clike_unportable_variant",
463 group: "correctness",
464 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
466 module: "enum_clike",
469 name: "enum_glob_use",
471 desc: "use items that import all variants of an enum",
473 module: "wildcard_imports",
476 name: "enum_variant_names",
478 desc: "enums where all variants share a prefix/postfix",
480 module: "enum_variants",
484 group: "correctness",
485 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
491 group: "correctness",
492 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
494 module: "erasing_op",
497 name: "eval_order_dependence",
499 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
501 module: "eval_order_dependence",
504 name: "excessive_precision",
506 desc: "excessive precision for float literal",
508 module: "float_literal",
512 group: "restriction",
513 desc: "`std::process::exit` is called, terminating the program",
518 name: "expect_fun_call",
520 desc: "using any `expect` method with a function call",
526 group: "restriction",
527 desc: "using `.expect()` on `Result` or `Option`, which might be better handled",
532 name: "expl_impl_clone_on_copy",
534 desc: "implementing `Clone` explicitly on `Copy` types",
539 name: "explicit_counter_loop",
541 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
546 name: "explicit_deref_methods",
548 desc: "Explicit use of deref or deref_mut method while not in a method chain.",
550 module: "dereference",
553 name: "explicit_into_iter_loop",
555 desc: "for-looping over `_.into_iter()` when `_` would do",
560 name: "explicit_iter_loop",
562 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
567 name: "explicit_write",
569 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
571 module: "explicit_write",
574 name: "extra_unused_lifetimes",
576 desc: "unused lifetimes in function definitions",
581 name: "fallible_impl_from",
583 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
585 module: "fallible_impl_from",
588 name: "filetype_is_file",
589 group: "restriction",
590 desc: "`FileType::is_file` is not recommended to test for readable file type",
597 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
602 name: "filter_map_next",
604 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
611 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
618 desc: "using a combination of `find` and `map` can usually be written as a single method call",
623 name: "flat_map_identity",
625 desc: "call to `flat_map` where `flatten` is sufficient",
630 name: "float_arithmetic",
631 group: "restriction",
632 desc: "any floating-point arithmetic statement",
634 module: "arithmetic",
638 group: "correctness",
639 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
644 name: "float_cmp_const",
645 group: "restriction",
646 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
651 name: "fn_address_comparisons",
652 group: "correctness",
653 desc: "comparison with an address of a function item",
655 module: "unnamed_address",
658 name: "fn_params_excessive_bools",
660 desc: "using too many bools in function parameters",
662 module: "excessive_bools",
665 name: "fn_to_numeric_cast",
667 desc: "casting a function pointer to a numeric type other than usize",
672 name: "fn_to_numeric_cast_with_truncation",
674 desc: "casting a function pointer to a numeric type not wide enough to store the address",
681 desc: "looping on a map using `iter` when `keys` or `values` would do",
686 name: "for_loops_over_fallibles",
687 group: "correctness",
688 desc: "for-looping over an `Option` or a `Result`, which is more clearly expressed as an `if let`",
694 group: "correctness",
695 desc: "calls to `std::mem::forget` with a value that implements Copy",
697 module: "drop_forget_ref",
701 group: "correctness",
702 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
704 module: "drop_forget_ref",
707 name: "future_not_send",
709 desc: "public Futures must be Send",
711 module: "future_not_send",
714 name: "get_last_with_len",
716 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
718 module: "get_last_with_len",
722 group: "restriction",
723 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
730 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
732 module: "identity_op",
735 name: "if_let_mutex",
736 group: "correctness",
737 desc: "locking a `Mutex` in an `if let` block can cause deadlocks",
739 module: "if_let_mutex",
742 name: "if_let_some_result",
744 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
746 module: "if_let_some_result",
751 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
753 module: "if_not_else",
756 name: "if_same_then_else",
757 group: "correctness",
758 desc: "`if` with the same `then` and `else` blocks",
763 name: "ifs_same_cond",
764 group: "correctness",
765 desc: "consecutive `if`s with the same condition",
770 name: "implicit_hasher",
772 desc: "missing generalization over different hashers",
777 name: "implicit_return",
778 group: "restriction",
779 desc: "use a return statement like `return expr` instead of an expression",
781 module: "implicit_return",
784 name: "implicit_saturating_sub",
786 desc: "Perform saturating subtraction instead of implicitly checking lower bound of data type",
788 module: "implicit_saturating_sub",
791 name: "imprecise_flops",
793 desc: "usage of imprecise floating point operations",
795 module: "floating_point_arithmetic",
798 name: "inconsistent_digit_grouping",
800 desc: "integer literals with digits grouped inconsistently",
802 module: "literal_representation",
805 name: "indexing_slicing",
806 group: "restriction",
807 desc: "indexing/slicing usage",
809 module: "indexing_slicing",
812 name: "ineffective_bit_mask",
813 group: "correctness",
814 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
819 name: "inefficient_to_string",
821 desc: "using `to_string` on `&&T` where `T: ToString`",
826 name: "infallible_destructuring_match",
828 desc: "a `match` statement with a single infallible arm instead of a `let`",
833 name: "infinite_iter",
834 group: "correctness",
835 desc: "infinite iteration",
837 module: "infinite_iter",
840 name: "inherent_to_string",
842 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
844 module: "inherent_to_string",
847 name: "inherent_to_string_shadow_display",
848 group: "correctness",
849 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait",
851 module: "inherent_to_string",
854 name: "inline_always",
856 desc: "use of `#[inline(always)]`",
861 name: "inline_fn_without_body",
862 group: "correctness",
863 desc: "use of `#[inline]` on trait methods without bodies",
865 module: "inline_fn_without_body",
868 name: "int_plus_one",
870 desc: "instead of using `x >= y + 1`, use `x > y`",
872 module: "int_plus_one",
875 name: "integer_arithmetic",
876 group: "restriction",
877 desc: "any integer arithmetic expression which could overflow or panic",
879 module: "arithmetic",
882 name: "integer_division",
883 group: "restriction",
884 desc: "integer division may cause loss of precision",
886 module: "integer_division",
889 name: "into_iter_on_ref",
891 desc: "using `.into_iter()` on a reference",
896 name: "invalid_atomic_ordering",
897 group: "correctness",
898 desc: "usage of invalid atomic ordering in atomic loads/stores and memory fences",
900 module: "atomic_ordering",
903 name: "invalid_regex",
904 group: "correctness",
905 desc: "invalid regular expressions",
910 name: "invalid_upcast_comparisons",
912 desc: "a comparison involving an upcast which is always true or false",
917 name: "items_after_statements",
919 desc: "blocks where an item comes after a statement",
921 module: "items_after_statements",
924 name: "iter_cloned_collect",
926 desc: "using `.cloned().collect()` on slice to create a `Vec`",
931 name: "iter_next_loop",
932 group: "correctness",
933 desc: "for-looping over `_.next()` which is probably not intended",
940 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
945 name: "iter_nth_zero",
947 desc: "replace `iter.nth(0)` with `iter.next()`",
952 name: "iter_skip_next",
954 desc: "using `.skip(x).next()` on an iterator",
959 name: "iterator_step_by_zero",
960 group: "correctness",
961 desc: "using `Iterator::step_by(0)`, which will panic at runtime",
966 name: "just_underscores_and_digits",
968 desc: "unclear name",
970 module: "non_expressive_names",
973 name: "large_const_arrays",
975 desc: "large non-scalar const array may cause performance overhead",
977 module: "large_const_arrays",
980 name: "large_digit_groups",
982 desc: "grouping digits into groups that are too large",
984 module: "literal_representation",
987 name: "large_enum_variant",
989 desc: "large size difference between variants on an enum",
991 module: "large_enum_variant",
994 name: "large_stack_arrays",
996 desc: "allocating large arrays on stack may cause stack overflow",
998 module: "large_stack_arrays",
1001 name: "len_without_is_empty",
1003 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
1010 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
1015 name: "let_and_return",
1017 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
1022 name: "let_underscore_lock",
1023 group: "correctness",
1024 desc: "non-binding let on a synchronization lock",
1026 module: "let_underscore",
1029 name: "let_underscore_must_use",
1030 group: "restriction",
1031 desc: "non-binding let on a `#[must_use]` expression",
1033 module: "let_underscore",
1036 name: "let_unit_value",
1038 desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
1045 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`",
1051 group: "correctness",
1052 desc: "boolean expressions that contain terminals which can be eliminated",
1057 name: "lossy_float_literal",
1058 group: "restriction",
1059 desc: "lossy whole number float literals",
1061 module: "float_literal",
1064 name: "macro_use_imports",
1066 desc: "#[macro_use] is no longer needed",
1068 module: "macro_use",
1071 name: "main_recursion",
1073 desc: "recursion using the entrypoint",
1075 module: "main_recursion",
1078 name: "manual_async_fn",
1080 desc: "manual implementations of `async` functions can be simplified using the dedicated syntax",
1082 module: "manual_async_fn",
1085 name: "manual_memcpy",
1087 desc: "manually copying items between slices",
1092 name: "manual_non_exhaustive",
1094 desc: "manual implementations of the non-exhaustive pattern can be simplified using #[non_exhaustive]",
1096 module: "manual_non_exhaustive",
1099 name: "manual_saturating_arithmetic",
1101 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
1106 name: "manual_swap",
1107 group: "complexity",
1108 desc: "manual swap of two variables",
1113 name: "many_single_char_names",
1115 desc: "too many single character bindings",
1117 module: "non_expressive_names",
1122 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1124 module: "map_clone",
1129 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1134 name: "map_flatten",
1136 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1141 name: "map_unwrap_or",
1143 desc: "using `.map(f).unwrap_or(a)` or `.map(f).unwrap_or_else(func)`, which are more succinctly expressed as `map_or(a, f)` or `map_or_else(a, f)`",
1148 name: "match_as_ref",
1149 group: "complexity",
1150 desc: "a `match` on an Option value instead of using `as_ref()` or `as_mut`",
1157 desc: "a `match` on a boolean expression instead of an `if..else` block",
1162 name: "match_on_vec_items",
1164 desc: "matching on vector elements can panic",
1166 module: "match_on_vec_items",
1169 name: "match_overlapping_arm",
1171 desc: "a `match` with overlapping arms",
1176 name: "match_ref_pats",
1178 desc: "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1183 name: "match_same_arms",
1185 desc: "`match` with identical arm bodies",
1190 name: "match_single_binding",
1191 group: "complexity",
1192 desc: "a match with a single binding instead of using `let` statement",
1197 name: "match_wild_err_arm",
1199 desc: "a `match` with `Err(_)` arm and take drastic actions",
1204 name: "match_wildcard_for_single_variants",
1206 desc: "a wildcard enum match for a single variant",
1211 name: "maybe_infinite_iter",
1213 desc: "possible infinite iteration",
1215 module: "infinite_iter",
1218 name: "mem_discriminant_non_enum",
1219 group: "correctness",
1220 desc: "calling `mem::descriminant` on non-enum type",
1222 module: "mem_discriminant",
1226 group: "restriction",
1227 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1229 module: "mem_forget",
1232 name: "mem_replace_option_with_none",
1234 desc: "replacing an `Option` with `None` instead of `take()`",
1236 module: "mem_replace",
1239 name: "mem_replace_with_default",
1241 desc: "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`",
1243 module: "mem_replace",
1246 name: "mem_replace_with_uninit",
1247 group: "correctness",
1248 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1250 module: "mem_replace",
1254 group: "correctness",
1255 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1260 name: "mismatched_target_os",
1261 group: "correctness",
1262 desc: "usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`",
1267 name: "misrefactored_assign_op",
1268 group: "complexity",
1269 desc: "having a variable on both sides of an assign op",
1271 module: "assign_ops",
1274 name: "missing_const_for_fn",
1276 desc: "Lint functions definitions that could be made `const fn`",
1278 module: "missing_const_for_fn",
1281 name: "missing_docs_in_private_items",
1282 group: "restriction",
1283 desc: "detects missing documentation for public and private members",
1285 module: "missing_doc",
1288 name: "missing_errors_doc",
1290 desc: "`pub fn` returns `Result` without `# Errors` in doc comment",
1295 name: "missing_inline_in_public_items",
1296 group: "restriction",
1297 desc: "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)",
1299 module: "missing_inline",
1302 name: "missing_safety_doc",
1304 desc: "`pub unsafe fn` without `# Safety` docs",
1309 name: "mistyped_literal_suffixes",
1310 group: "correctness",
1311 desc: "mistyped literal suffix",
1313 module: "literal_representation",
1316 name: "mixed_case_hex_literals",
1318 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1320 module: "misc_early",
1323 name: "module_inception",
1325 desc: "modules that have the same name as their parent module",
1327 module: "enum_variants",
1330 name: "module_name_repetitions",
1332 desc: "type names prefixed/postfixed with their containing module\'s name",
1334 module: "enum_variants",
1337 name: "modulo_arithmetic",
1338 group: "restriction",
1339 desc: "any modulo arithmetic statement",
1341 module: "modulo_arithmetic",
1345 group: "correctness",
1346 desc: "taking a number modulo 1, which always returns 0",
1351 name: "multiple_crate_versions",
1353 desc: "multiple versions of the same crate being used",
1355 module: "multiple_crate_versions",
1358 name: "multiple_inherent_impl",
1359 group: "restriction",
1360 desc: "Multiple inherent impl that could be grouped",
1362 module: "inherent_impl",
1365 name: "must_use_candidate",
1367 desc: "function or method that could take a `#[must_use]` attribute",
1369 module: "functions",
1372 name: "must_use_unit",
1374 desc: "`#[must_use]` attribute on a unit-returning function / method",
1376 module: "functions",
1379 name: "mut_from_ref",
1380 group: "correctness",
1381 desc: "fns that create mutable refs from immutable ref args",
1388 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1393 name: "mut_range_bound",
1394 group: "complexity",
1395 desc: "for loop over a range where one of the bounds is a mutable variable",
1400 name: "mutable_key_type",
1401 group: "correctness",
1402 desc: "Check for mutable `Map`/`Set` key type",
1407 name: "mutex_atomic",
1409 desc: "using a mutex where an atomic value could be used instead",
1411 module: "mutex_atomic",
1414 name: "mutex_integer",
1416 desc: "using a mutex for an integer type",
1418 module: "mutex_atomic",
1421 name: "naive_bytecount",
1423 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1425 module: "bytecount",
1428 name: "needless_bool",
1429 group: "complexity",
1430 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1432 module: "needless_bool",
1435 name: "needless_borrow",
1437 desc: "taking a reference that is going to be automatically dereferenced",
1439 module: "needless_borrow",
1442 name: "needless_borrowed_reference",
1443 group: "complexity",
1444 desc: "taking a needless borrowed reference",
1446 module: "needless_borrowed_ref",
1449 name: "needless_collect",
1451 desc: "collecting an iterator when collect is not needed",
1456 name: "needless_continue",
1458 desc: "`continue` statements that can be replaced by a rearrangement of code",
1460 module: "needless_continue",
1463 name: "needless_doctest_main",
1465 desc: "presence of `fn main() {` in code examples",
1470 name: "needless_lifetimes",
1471 group: "complexity",
1472 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1474 module: "lifetimes",
1477 name: "needless_pass_by_value",
1479 desc: "functions taking arguments by value, but not consuming them in its body",
1481 module: "needless_pass_by_value",
1484 name: "needless_range_loop",
1486 desc: "for-looping over a range of indices where an iterator over items would do",
1491 name: "needless_return",
1493 desc: "using a return statement like `return expr;` where an expression would suffice",
1498 name: "needless_update",
1499 group: "complexity",
1500 desc: "using `Foo { ..base }` when there are no missing fields",
1502 module: "needless_update",
1505 name: "neg_cmp_op_on_partial_ord",
1506 group: "complexity",
1507 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1509 module: "neg_cmp_op_on_partial_ord",
1512 name: "neg_multiply",
1514 desc: "multiplying integers with `-1`",
1516 module: "neg_multiply",
1520 group: "correctness",
1521 desc: "any loop that will always `break` or `return`",
1526 name: "new_ret_no_self",
1528 desc: "not returning type containing `Self` in a `new` method",
1533 name: "new_without_default",
1535 desc: "`fn new() -> Self` method without `Default` implementation",
1537 module: "new_without_default",
1541 group: "complexity",
1542 desc: "statements with no effect",
1544 module: "no_effect",
1547 name: "non_ascii_literal",
1549 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1554 name: "nonminimal_bool",
1555 group: "complexity",
1556 desc: "boolean expressions that can be written more concisely",
1561 name: "nonsensical_open_options",
1562 group: "correctness",
1563 desc: "nonsensical combination of options for opening a file",
1565 module: "open_options",
1568 name: "not_unsafe_ptr_arg_deref",
1569 group: "correctness",
1570 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1572 module: "functions",
1577 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1584 desc: "taking a reference to satisfy the type constraints on `==`",
1589 name: "option_as_ref_deref",
1590 group: "complexity",
1591 desc: "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`",
1596 name: "option_env_unwrap",
1597 group: "correctness",
1598 desc: "using `option_env!(...).unwrap()` to get environment variable",
1600 module: "option_env_unwrap",
1603 name: "option_map_or_none",
1605 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1610 name: "option_map_unit_fn",
1611 group: "complexity",
1612 desc: "using `option.map(f)`, where `f` is a function or closure that returns `()`",
1614 module: "map_unit_fn",
1617 name: "option_option",
1619 desc: "usage of `Option<Option<T>>`",
1624 name: "or_fun_call",
1626 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1631 name: "out_of_bounds_indexing",
1632 group: "correctness",
1633 desc: "out of bounds constant indexing",
1635 module: "indexing_slicing",
1638 name: "overflow_check_conditional",
1639 group: "complexity",
1640 desc: "overflow checks inspired by C which are likely to panic",
1642 module: "overflow_check_conditional",
1646 group: "restriction",
1647 desc: "usage of the `panic!` macro",
1649 module: "panic_unimplemented",
1652 name: "panic_params",
1654 desc: "missing parameters in `panic!` calls",
1656 module: "panic_unimplemented",
1659 name: "panicking_unwrap",
1660 group: "correctness",
1661 desc: "checks for calls of `unwrap[_err]()` that will always fail",
1666 name: "partialeq_ne_impl",
1667 group: "complexity",
1668 desc: "re-implementing `PartialEq::ne`",
1670 module: "partialeq_ne_impl",
1673 name: "path_buf_push_overwrite",
1675 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1677 module: "path_buf_push_overwrite",
1680 name: "possible_missing_comma",
1681 group: "correctness",
1682 desc: "possible missing comma in array",
1684 module: "formatting",
1688 group: "complexity",
1689 desc: "operations where precedence may be unclear",
1691 module: "precedence",
1694 name: "print_literal",
1696 desc: "printing a literal with a format string",
1701 name: "print_stdout",
1702 group: "restriction",
1703 desc: "printing on stdout",
1708 name: "print_with_newline",
1710 desc: "using `print!()` with a format string that ends in a single newline",
1715 name: "println_empty_string",
1717 desc: "using `println!(\"\")` with an empty string",
1724 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1729 name: "ptr_offset_with_cast",
1730 group: "complexity",
1731 desc: "unneeded pointer offset cast",
1733 module: "ptr_offset_with_cast",
1736 name: "pub_enum_variant_names",
1738 desc: "enums where all variants share a prefix/postfix",
1740 module: "enum_variants",
1743 name: "question_mark",
1745 desc: "checks for expressions that could be replaced by the question mark operator",
1747 module: "question_mark",
1750 name: "range_minus_one",
1751 group: "complexity",
1752 desc: "`x..=(y-1)` reads better as `x..y`",
1757 name: "range_plus_one",
1759 desc: "`x..(y+1)` reads better as `x..=y`",
1764 name: "range_zip_with_len",
1765 group: "complexity",
1766 desc: "zipping iterator with a range when `enumerate()` would do",
1771 name: "redundant_allocation",
1773 desc: "redundant allocation",
1778 name: "redundant_clone",
1780 desc: "`clone()` of an owned value that is going to be dropped immediately",
1782 module: "redundant_clone",
1785 name: "redundant_closure",
1787 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1789 module: "eta_reduction",
1792 name: "redundant_closure_call",
1793 group: "complexity",
1794 desc: "throwaway closures called in the expression they are defined",
1796 module: "misc_early",
1799 name: "redundant_closure_for_method_calls",
1801 desc: "redundant closures for method calls",
1803 module: "eta_reduction",
1806 name: "redundant_field_names",
1808 desc: "checks for fields in struct literals where shorthands could be used",
1810 module: "redundant_field_names",
1813 name: "redundant_pattern",
1815 desc: "using `name @ _` in a pattern",
1817 module: "misc_early",
1820 name: "redundant_pattern_matching",
1822 desc: "use the proper utility function avoiding an `if let`",
1824 module: "redundant_pattern_matching",
1827 name: "redundant_pub_crate",
1829 desc: "Using `pub(crate)` visibility on items that are not crate visible due to the visibility of the module that contains them.",
1831 module: "redundant_pub_crate",
1834 name: "redundant_static_lifetimes",
1836 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1838 module: "redundant_static_lifetimes",
1841 name: "ref_in_deref",
1842 group: "complexity",
1843 desc: "Use of reference in auto dereference expression.",
1845 module: "reference",
1848 name: "regex_macro",
1850 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1855 name: "rest_pat_in_fully_bound_structs",
1856 group: "restriction",
1857 desc: "a match on a struct that binds all fields but still uses the wildcard pattern",
1862 name: "result_map_or_into_option",
1864 desc: "using `Result.map_or(None, Some)`, which is more succinctly expressed as `ok()`",
1869 name: "result_map_unit_fn",
1870 group: "complexity",
1871 desc: "using `result.map(f)`, where `f` is a function or closure that returns `()`",
1873 module: "map_unit_fn",
1876 name: "reversed_empty_ranges",
1877 group: "correctness",
1878 desc: "reversing the limits of range expressions, resulting in empty ranges",
1883 name: "same_functions_in_if_condition",
1885 desc: "consecutive `if`s with the same function call",
1890 name: "search_is_some",
1891 group: "complexity",
1892 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1897 name: "serde_api_misuse",
1898 group: "correctness",
1899 desc: "various things that will negatively affect your serde experience",
1901 module: "serde_api",
1904 name: "shadow_reuse",
1905 group: "restriction",
1906 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1911 name: "shadow_same",
1912 group: "restriction",
1913 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1918 name: "shadow_unrelated",
1920 desc: "rebinding a name without even using the original value",
1925 name: "short_circuit_statement",
1926 group: "complexity",
1927 desc: "using a short circuit boolean condition as a statement",
1932 name: "should_implement_trait",
1934 desc: "defining a method that should be implementing a std trait",
1939 name: "similar_names",
1941 desc: "similarly named items and bindings",
1943 module: "non_expressive_names",
1946 name: "single_char_pattern",
1948 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1953 name: "single_component_path_imports",
1955 desc: "imports with single component path are redundant",
1957 module: "single_component_path_imports",
1960 name: "single_match",
1962 desc: "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1967 name: "single_match_else",
1969 desc: "a `match` statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1974 name: "skip_while_next",
1975 group: "complexity",
1976 desc: "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`",
1981 name: "slow_vector_initialization",
1983 desc: "slow vector initialization",
1985 module: "slow_vector_initialization",
1989 group: "restriction",
1990 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1995 name: "string_add_assign",
1997 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
2002 name: "string_extend_chars",
2004 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
2009 name: "string_lit_as_bytes",
2011 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
2016 name: "struct_excessive_bools",
2018 desc: "using too many bools in a struct",
2020 module: "excessive_bools",
2023 name: "suboptimal_flops",
2025 desc: "usage of sub-optimal floating point operations",
2027 module: "floating_point_arithmetic",
2030 name: "suspicious_arithmetic_impl",
2031 group: "correctness",
2032 desc: "suspicious use of operators in impl of arithmetic trait",
2034 module: "suspicious_trait_impl",
2037 name: "suspicious_assignment_formatting",
2039 desc: "suspicious formatting of `*=`, `-=` or `!=`",
2041 module: "formatting",
2044 name: "suspicious_else_formatting",
2046 desc: "suspicious formatting of `else`",
2048 module: "formatting",
2051 name: "suspicious_map",
2052 group: "complexity",
2053 desc: "suspicious usage of map",
2058 name: "suspicious_op_assign_impl",
2059 group: "correctness",
2060 desc: "suspicious use of operators in impl of OpAssign trait",
2062 module: "suspicious_trait_impl",
2065 name: "suspicious_unary_op_formatting",
2067 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
2069 module: "formatting",
2072 name: "tabs_in_doc_comments",
2074 desc: "using tabs in doc comments is not recommended",
2076 module: "tabs_in_doc_comments",
2079 name: "temporary_assignment",
2080 group: "complexity",
2081 desc: "assignments to temporaries",
2083 module: "temporary_assignment",
2086 name: "temporary_cstring_as_ptr",
2087 group: "correctness",
2088 desc: "getting the inner pointer of a temporary `CString`",
2093 name: "to_digit_is_some",
2095 desc: "`char.is_digit()` is clearer",
2097 module: "to_digit_is_some",
2101 group: "restriction",
2102 desc: "`todo!` should not be present in production code",
2104 module: "panic_unimplemented",
2107 name: "too_many_arguments",
2108 group: "complexity",
2109 desc: "functions with too many arguments",
2111 module: "functions",
2114 name: "too_many_lines",
2116 desc: "functions with too many lines",
2118 module: "functions",
2121 name: "toplevel_ref_arg",
2123 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
2128 name: "transmute_bytes_to_str",
2129 group: "complexity",
2130 desc: "transmutes from a `&[u8]` to a `&str`",
2132 module: "transmute",
2135 name: "transmute_float_to_int",
2136 group: "complexity",
2137 desc: "transmutes from a float to an integer",
2139 module: "transmute",
2142 name: "transmute_int_to_bool",
2143 group: "complexity",
2144 desc: "transmutes from an integer to a `bool`",
2146 module: "transmute",
2149 name: "transmute_int_to_char",
2150 group: "complexity",
2151 desc: "transmutes from an integer to a `char`",
2153 module: "transmute",
2156 name: "transmute_int_to_float",
2157 group: "complexity",
2158 desc: "transmutes from an integer to a float",
2160 module: "transmute",
2163 name: "transmute_ptr_to_ptr",
2164 group: "complexity",
2165 desc: "transmutes from a pointer to a pointer / a reference to a reference",
2167 module: "transmute",
2170 name: "transmute_ptr_to_ref",
2171 group: "complexity",
2172 desc: "transmutes from a pointer to a reference type",
2174 module: "transmute",
2177 name: "transmuting_null",
2178 group: "correctness",
2179 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
2181 module: "transmuting_null",
2184 name: "trivial_regex",
2186 desc: "trivial regular expressions",
2191 name: "trivially_copy_pass_by_ref",
2193 desc: "functions taking small copyable arguments by reference",
2195 module: "trivially_copy_pass_by_ref",
2200 desc: "return errors explicitly rather than hiding them behind a `?`",
2205 name: "type_complexity",
2206 group: "complexity",
2207 desc: "usage of very complex types that might be better factored into `type` definitions",
2212 name: "type_repetition_in_bounds",
2214 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2216 module: "trait_bounds",
2219 name: "unicode_not_nfc",
2221 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2226 name: "unimplemented",
2227 group: "restriction",
2228 desc: "`unimplemented!` should not be present in production code",
2230 module: "panic_unimplemented",
2233 name: "uninit_assumed_init",
2234 group: "correctness",
2235 desc: "`MaybeUninit::uninit().assume_init()`",
2241 group: "complexity",
2242 desc: "passing unit to a function",
2248 group: "correctness",
2249 desc: "comparing unit values",
2254 name: "unknown_clippy_lints",
2256 desc: "unknown_lints for scoped Clippy lints",
2261 name: "unnecessary_cast",
2262 group: "complexity",
2263 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2268 name: "unnecessary_filter_map",
2269 group: "complexity",
2270 desc: "using `filter_map` when a more succinct alternative exists",
2275 name: "unnecessary_fold",
2277 desc: "using `fold` when a more succinct alternative exists",
2282 name: "unnecessary_mut_passed",
2284 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2286 module: "mut_reference",
2289 name: "unnecessary_operation",
2290 group: "complexity",
2291 desc: "outer expressions with no effect",
2293 module: "no_effect",
2296 name: "unnecessary_sort_by",
2297 group: "complexity",
2298 desc: "Use of `Vec::sort_by` when `Vec::sort_by_key` or `Vec::sort` would be clearer",
2300 module: "unnecessary_sort_by",
2303 name: "unnecessary_unwrap",
2304 group: "complexity",
2305 desc: "checks for calls of `unwrap[_err]()` that cannot fail",
2310 name: "unneeded_field_pattern",
2311 group: "restriction",
2312 desc: "struct fields bound to a wildcard instead of using `..`",
2314 module: "misc_early",
2317 name: "unneeded_wildcard_pattern",
2318 group: "complexity",
2319 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2321 module: "misc_early",
2324 name: "unreachable",
2325 group: "restriction",
2326 desc: "`unreachable!` should not be present in production code",
2328 module: "panic_unimplemented",
2331 name: "unreadable_literal",
2333 desc: "long integer literal without underscores",
2335 module: "literal_representation",
2338 name: "unsafe_derive_deserialize",
2340 desc: "deriving `serde::Deserialize` on a type that has methods using `unsafe`",
2345 name: "unsafe_removed_from_name",
2347 desc: "`unsafe` removed from API names on import",
2349 module: "unsafe_removed_from_name",
2352 name: "unseparated_literal_suffix",
2354 desc: "literals whose suffix is not separated by an underscore",
2356 module: "misc_early",
2359 name: "unsound_collection_transmute",
2360 group: "correctness",
2361 desc: "transmute between collections of layout-incompatible types",
2363 module: "transmute",
2366 name: "unused_io_amount",
2367 group: "correctness",
2368 desc: "unused written/read amount",
2370 module: "unused_io_amount",
2373 name: "unused_self",
2375 desc: "methods that contain a `self` argument but don\'t use it",
2377 module: "unused_self",
2380 name: "unused_unit",
2382 desc: "needless unit expression",
2387 name: "unwrap_used",
2388 group: "restriction",
2389 desc: "using `.unwrap()` on `Result` or `Option`, which should at least get a better message using `expect()`",
2395 group: "restriction",
2396 desc: "use of `Debug`-based formatting",
2403 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2408 name: "used_underscore_binding",
2410 desc: "using a binding which is prefixed with an underscore",
2415 name: "useless_asref",
2416 group: "complexity",
2417 desc: "using `as_ref` where the types before and after the call are the same",
2422 name: "useless_attribute",
2423 group: "correctness",
2424 desc: "use of lint attributes on `extern crate` items",
2429 name: "useless_conversion",
2430 group: "complexity",
2431 desc: "calls to `Into`, `TryInto`, `From`, `TryFrom`, `IntoIter` that performs useless conversions to the same type",
2433 module: "useless_conversion",
2436 name: "useless_format",
2437 group: "complexity",
2438 desc: "useless use of `format!`",
2443 name: "useless_let_if_seq",
2445 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2447 module: "let_if_seq",
2450 name: "useless_transmute",
2452 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2454 module: "transmute",
2457 name: "useless_vec",
2459 desc: "useless `vec!`",
2465 group: "complexity",
2466 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2471 name: "vec_resize_to_zero",
2472 group: "correctness",
2473 desc: "emptying a vector with `resize(0, an_int)` instead of `clear()` is probably an argument inversion mistake",
2475 module: "vec_resize_to_zero",
2478 name: "verbose_bit_mask",
2480 desc: "expressions where a bit mask is less readable than the corresponding method call",
2485 name: "verbose_file_reads",
2486 group: "restriction",
2487 desc: "use of `File::read_to_end` or `File::read_to_string`",
2489 module: "verbose_file_reads",
2492 name: "vtable_address_comparisons",
2493 group: "correctness",
2494 desc: "comparison with an address of a trait vtable",
2496 module: "unnamed_address",
2499 name: "while_immutable_condition",
2500 group: "correctness",
2501 desc: "variables used within while expression are not mutated in the body",
2506 name: "while_let_loop",
2507 group: "complexity",
2508 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2513 name: "while_let_on_iterator",
2515 desc: "using a while-let loop instead of a for loop on an iterator",
2520 name: "wildcard_dependencies",
2522 desc: "wildcard dependencies being used",
2524 module: "wildcard_dependencies",
2527 name: "wildcard_enum_match_arm",
2528 group: "restriction",
2529 desc: "a wildcard enum match arm using `_`",
2534 name: "wildcard_imports",
2536 desc: "lint `use _::*` statements",
2538 module: "wildcard_imports",
2541 name: "wildcard_in_or_patterns",
2542 group: "complexity",
2543 desc: "a wildcard pattern used with others patterns in same match arm",
2548 name: "write_literal",
2550 desc: "writing a literal with a format string",
2555 name: "write_with_newline",
2557 desc: "using `write!()` with a format string that ends in a single newline",
2562 name: "writeln_empty_string",
2564 desc: "using `writeln!(buf, \"\")` with an empty string",
2569 name: "wrong_pub_self_convention",
2570 group: "restriction",
2571 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2576 name: "wrong_self_convention",
2578 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2583 name: "wrong_transmute",
2584 group: "correctness",
2585 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2587 module: "transmute",
2590 name: "zero_divided_by_zero",
2591 group: "complexity",
2592 desc: "usage of `0.0 / 0.0` to obtain NaN instead of `f32::NAN` or `f64::NAN`",
2594 module: "zero_div_zero",
2597 name: "zero_prefixed_literal",
2598 group: "complexity",
2599 desc: "integer literals starting with `0`",
2601 module: "misc_early",
2606 desc: "using `0 as *{const, mut} T`",
2611 name: "zero_width_space",
2612 group: "correctness",
2613 desc: "using a zero-width space in a string literal, which is confusing",
2619 group: "correctness",
2620 desc: "Check for offset calculations on raw pointers to zero-sized types",
2625 // end lint list, do not remove this comment, it’s used in `update_lints`