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: "blacklisted_name",
72 desc: "usage of a blacklisted/placeholder name",
74 module: "blacklisted_name",
77 name: "block_in_if_condition_expr",
79 desc: "braces that can be eliminated in conditions, e.g., `if { true } ...`",
81 module: "block_in_if_condition",
84 name: "block_in_if_condition_stmt",
86 desc: "complex blocks in conditions, e.g., `if { let x = true; x } ...`",
88 module: "block_in_if_condition",
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",
169 group: "correctness",
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",
525 name: "expl_impl_clone_on_copy",
527 desc: "implementing `Clone` explicitly on `Copy` types",
532 name: "explicit_counter_loop",
534 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
539 name: "explicit_deref_methods",
541 desc: "Explicit use of deref or deref_mut method while not in a method chain.",
543 module: "dereference",
546 name: "explicit_into_iter_loop",
548 desc: "for-looping over `_.into_iter()` when `_` would do",
553 name: "explicit_iter_loop",
555 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
560 name: "explicit_write",
562 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
564 module: "explicit_write",
567 name: "extra_unused_lifetimes",
569 desc: "unused lifetimes in function definitions",
574 name: "fallible_impl_from",
576 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
578 module: "fallible_impl_from",
581 name: "filetype_is_file",
582 group: "restriction",
583 desc: "`FileType::is_file` is not recommended to test for readable file type",
590 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
595 name: "filter_map_next",
597 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
604 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
611 desc: "using a combination of `find` and `map` can usually be written as a single method call",
616 name: "flat_map_identity",
618 desc: "call to `flat_map` where `flatten` is sufficient",
623 name: "float_arithmetic",
624 group: "restriction",
625 desc: "any floating-point arithmetic statement",
627 module: "arithmetic",
631 group: "correctness",
632 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
637 name: "float_cmp_const",
638 group: "restriction",
639 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
644 name: "fn_address_comparisons",
645 group: "correctness",
646 desc: "comparison with an address of a function item",
648 module: "unnamed_address",
651 name: "fn_params_excessive_bools",
653 desc: "using too many bools in function parameters",
655 module: "excessive_bools",
658 name: "fn_to_numeric_cast",
660 desc: "casting a function pointer to a numeric type other than usize",
665 name: "fn_to_numeric_cast_with_truncation",
667 desc: "casting a function pointer to a numeric type not wide enough to store the address",
674 desc: "looping on a map using `iter` when `keys` or `values` would do",
679 name: "for_loop_over_option",
680 group: "correctness",
681 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
686 name: "for_loop_over_result",
687 group: "correctness",
688 desc: "for-looping over 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",
728 name: "identity_conversion",
730 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
732 module: "identity_conversion",
737 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
739 module: "identity_op",
742 name: "if_let_mutex",
743 group: "correctness",
744 desc: "locking a `Mutex` in an `if let` block can cause deadlocks",
746 module: "if_let_mutex",
749 name: "if_let_some_result",
751 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
753 module: "if_let_some_result",
758 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
760 module: "if_not_else",
763 name: "if_same_then_else",
764 group: "correctness",
765 desc: "`if` with the same `then` and `else` blocks",
770 name: "ifs_same_cond",
771 group: "correctness",
772 desc: "consecutive `if`s with the same condition",
777 name: "implicit_hasher",
779 desc: "missing generalization over different hashers",
784 name: "implicit_return",
785 group: "restriction",
786 desc: "use a return statement like `return expr` instead of an expression",
788 module: "implicit_return",
791 name: "implicit_saturating_sub",
793 desc: "Perform saturating subtraction instead of implicitly checking lower bound of data type",
795 module: "implicit_saturating_sub",
798 name: "imprecise_flops",
800 desc: "usage of imprecise floating point operations",
802 module: "floating_point_arithmetic",
805 name: "inconsistent_digit_grouping",
807 desc: "integer literals with digits grouped inconsistently",
809 module: "literal_representation",
812 name: "indexing_slicing",
813 group: "restriction",
814 desc: "indexing/slicing usage",
816 module: "indexing_slicing",
819 name: "ineffective_bit_mask",
820 group: "correctness",
821 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
826 name: "inefficient_to_string",
828 desc: "using `to_string` on `&&T` where `T: ToString`",
833 name: "infallible_destructuring_match",
835 desc: "a `match` statement with a single infallible arm instead of a `let`",
840 name: "infinite_iter",
841 group: "correctness",
842 desc: "infinite iteration",
844 module: "infinite_iter",
847 name: "inherent_to_string",
849 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
851 module: "inherent_to_string",
854 name: "inherent_to_string_shadow_display",
855 group: "correctness",
856 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait",
858 module: "inherent_to_string",
861 name: "inline_always",
863 desc: "use of `#[inline(always)]`",
868 name: "inline_fn_without_body",
869 group: "correctness",
870 desc: "use of `#[inline]` on trait methods without bodies",
872 module: "inline_fn_without_body",
875 name: "int_plus_one",
877 desc: "instead of using `x >= y + 1`, use `x > y`",
879 module: "int_plus_one",
882 name: "integer_arithmetic",
883 group: "restriction",
884 desc: "any integer arithmetic expression which could overflow or panic",
886 module: "arithmetic",
889 name: "integer_division",
890 group: "restriction",
891 desc: "integer division may cause loss of precision",
893 module: "integer_division",
896 name: "into_iter_on_ref",
898 desc: "using `.into_iter()` on a reference",
903 name: "invalid_atomic_ordering",
904 group: "correctness",
905 desc: "usage of invalid atomic ordering in atomic loads/stores and memory fences",
907 module: "atomic_ordering",
910 name: "invalid_regex",
911 group: "correctness",
912 desc: "invalid regular expressions",
917 name: "invalid_upcast_comparisons",
919 desc: "a comparison involving an upcast which is always true or false",
924 name: "items_after_statements",
926 desc: "blocks where an item comes after a statement",
928 module: "items_after_statements",
931 name: "iter_cloned_collect",
933 desc: "using `.cloned().collect()` on slice to create a `Vec`",
938 name: "iter_next_loop",
939 group: "correctness",
940 desc: "for-looping over `_.next()` which is probably not intended",
947 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
952 name: "iter_nth_zero",
954 desc: "replace `iter.nth(0)` with `iter.next()`",
959 name: "iter_skip_next",
961 desc: "using `.skip(x).next()` on an iterator",
966 name: "iterator_step_by_zero",
967 group: "correctness",
968 desc: "using `Iterator::step_by(0)`, which will panic at runtime",
973 name: "just_underscores_and_digits",
975 desc: "unclear name",
977 module: "non_expressive_names",
980 name: "large_const_arrays",
982 desc: "large non-scalar const array may cause performance overhead",
984 module: "large_const_arrays",
987 name: "large_digit_groups",
989 desc: "grouping digits into groups that are too large",
991 module: "literal_representation",
994 name: "large_enum_variant",
996 desc: "large size difference between variants on an enum",
998 module: "large_enum_variant",
1001 name: "large_stack_arrays",
1003 desc: "allocating large arrays on stack may cause stack overflow",
1005 module: "large_stack_arrays",
1008 name: "len_without_is_empty",
1010 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
1017 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
1022 name: "let_and_return",
1024 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
1029 name: "let_underscore_lock",
1030 group: "correctness",
1031 desc: "non-binding let on a synchronization lock",
1033 module: "let_underscore",
1036 name: "let_underscore_must_use",
1037 group: "restriction",
1038 desc: "non-binding let on a `#[must_use]` expression",
1040 module: "let_underscore",
1043 name: "let_unit_value",
1045 desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
1052 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`",
1058 group: "correctness",
1059 desc: "boolean expressions that contain terminals which can be eliminated",
1064 name: "lossy_float_literal",
1065 group: "restriction",
1066 desc: "lossy whole number float literals",
1068 module: "float_literal",
1071 name: "macro_use_imports",
1073 desc: "#[macro_use] is no longer needed",
1075 module: "macro_use",
1078 name: "main_recursion",
1080 desc: "recursion using the entrypoint",
1082 module: "main_recursion",
1085 name: "manual_memcpy",
1087 desc: "manually copying items between slices",
1092 name: "manual_saturating_arithmetic",
1094 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
1099 name: "manual_swap",
1100 group: "complexity",
1101 desc: "manual swap of two variables",
1106 name: "many_single_char_names",
1108 desc: "too many single character bindings",
1110 module: "non_expressive_names",
1115 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1117 module: "map_clone",
1122 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1127 name: "map_flatten",
1129 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1134 name: "match_as_ref",
1135 group: "complexity",
1136 desc: "a `match` on an Option value instead of using `as_ref()` or `as_mut`",
1143 desc: "a `match` on a boolean expression instead of an `if..else` block",
1148 name: "match_overlapping_arm",
1150 desc: "a `match` with overlapping arms",
1155 name: "match_ref_pats",
1157 desc: "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1162 name: "match_same_arms",
1164 desc: "`match` with identical arm bodies",
1169 name: "match_single_binding",
1170 group: "complexity",
1171 desc: "a match with a single binding instead of using `let` statement",
1176 name: "match_wild_err_arm",
1178 desc: "a `match` with `Err(_)` arm and take drastic actions",
1183 name: "maybe_infinite_iter",
1185 desc: "possible infinite iteration",
1187 module: "infinite_iter",
1190 name: "mem_discriminant_non_enum",
1191 group: "correctness",
1192 desc: "calling `mem::descriminant` on non-enum type",
1194 module: "mem_discriminant",
1198 group: "restriction",
1199 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1201 module: "mem_forget",
1204 name: "mem_replace_option_with_none",
1206 desc: "replacing an `Option` with `None` instead of `take()`",
1208 module: "mem_replace",
1211 name: "mem_replace_with_default",
1213 desc: "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`",
1215 module: "mem_replace",
1218 name: "mem_replace_with_uninit",
1219 group: "correctness",
1220 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1222 module: "mem_replace",
1226 group: "correctness",
1227 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1232 name: "misrefactored_assign_op",
1233 group: "complexity",
1234 desc: "having a variable on both sides of an assign op",
1236 module: "assign_ops",
1239 name: "missing_const_for_fn",
1241 desc: "Lint functions definitions that could be made `const fn`",
1243 module: "missing_const_for_fn",
1246 name: "missing_docs_in_private_items",
1247 group: "restriction",
1248 desc: "detects missing documentation for public and private members",
1250 module: "missing_doc",
1253 name: "missing_errors_doc",
1255 desc: "`pub fn` returns `Result` without `# Errors` in doc comment",
1260 name: "missing_inline_in_public_items",
1261 group: "restriction",
1262 desc: "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)",
1264 module: "missing_inline",
1267 name: "missing_safety_doc",
1269 desc: "`pub unsafe fn` without `# Safety` docs",
1274 name: "mistyped_literal_suffixes",
1275 group: "correctness",
1276 desc: "mistyped literal suffix",
1278 module: "literal_representation",
1281 name: "mixed_case_hex_literals",
1283 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1285 module: "misc_early",
1288 name: "module_inception",
1290 desc: "modules that have the same name as their parent module",
1292 module: "enum_variants",
1295 name: "module_name_repetitions",
1297 desc: "type names prefixed/postfixed with their containing module\'s name",
1299 module: "enum_variants",
1302 name: "modulo_arithmetic",
1303 group: "restriction",
1304 desc: "any modulo arithmetic statement",
1306 module: "modulo_arithmetic",
1310 group: "correctness",
1311 desc: "taking a number modulo 1, which always returns 0",
1316 name: "multiple_crate_versions",
1318 desc: "multiple versions of the same crate being used",
1320 module: "multiple_crate_versions",
1323 name: "multiple_inherent_impl",
1324 group: "restriction",
1325 desc: "Multiple inherent impl that could be grouped",
1327 module: "inherent_impl",
1330 name: "must_use_candidate",
1332 desc: "function or method that could take a `#[must_use]` attribute",
1334 module: "functions",
1337 name: "must_use_unit",
1339 desc: "`#[must_use]` attribute on a unit-returning function / method",
1341 module: "functions",
1344 name: "mut_from_ref",
1345 group: "correctness",
1346 desc: "fns that create mutable refs from immutable ref args",
1353 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1358 name: "mut_range_bound",
1359 group: "complexity",
1360 desc: "for loop over a range where one of the bounds is a mutable variable",
1365 name: "mutable_key_type",
1366 group: "correctness",
1367 desc: "Check for mutable `Map`/`Set` key type",
1372 name: "mutex_atomic",
1374 desc: "using a mutex where an atomic value could be used instead",
1376 module: "mutex_atomic",
1379 name: "mutex_integer",
1381 desc: "using a mutex for an integer type",
1383 module: "mutex_atomic",
1386 name: "naive_bytecount",
1388 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1390 module: "bytecount",
1393 name: "needless_bool",
1394 group: "complexity",
1395 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1397 module: "needless_bool",
1400 name: "needless_borrow",
1402 desc: "taking a reference that is going to be automatically dereferenced",
1404 module: "needless_borrow",
1407 name: "needless_borrowed_reference",
1408 group: "complexity",
1409 desc: "taking a needless borrowed reference",
1411 module: "needless_borrowed_ref",
1414 name: "needless_collect",
1416 desc: "collecting an iterator when collect is not needed",
1421 name: "needless_continue",
1423 desc: "`continue` statements that can be replaced by a rearrangement of code",
1425 module: "needless_continue",
1428 name: "needless_doctest_main",
1430 desc: "presence of `fn main() {` in code examples",
1435 name: "needless_lifetimes",
1436 group: "complexity",
1437 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1439 module: "lifetimes",
1442 name: "needless_pass_by_value",
1444 desc: "functions taking arguments by value, but not consuming them in its body",
1446 module: "needless_pass_by_value",
1449 name: "needless_range_loop",
1451 desc: "for-looping over a range of indices where an iterator over items would do",
1456 name: "needless_return",
1458 desc: "using a return statement like `return expr;` where an expression would suffice",
1463 name: "needless_update",
1464 group: "complexity",
1465 desc: "using `Foo { ..base }` when there are no missing fields",
1467 module: "needless_update",
1470 name: "neg_cmp_op_on_partial_ord",
1471 group: "complexity",
1472 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1474 module: "neg_cmp_op_on_partial_ord",
1477 name: "neg_multiply",
1479 desc: "multiplying integers with `-1`",
1481 module: "neg_multiply",
1485 group: "correctness",
1486 desc: "any loop that will always `break` or `return`",
1491 name: "new_ret_no_self",
1493 desc: "not returning type containing `Self` in a `new` method",
1498 name: "new_without_default",
1500 desc: "`fn new() -> Self` method without `Default` implementation",
1502 module: "new_without_default",
1506 group: "complexity",
1507 desc: "statements with no effect",
1509 module: "no_effect",
1512 name: "non_ascii_literal",
1514 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1519 name: "nonminimal_bool",
1520 group: "complexity",
1521 desc: "boolean expressions that can be written more concisely",
1526 name: "nonsensical_open_options",
1527 group: "correctness",
1528 desc: "nonsensical combination of options for opening a file",
1530 module: "open_options",
1533 name: "not_unsafe_ptr_arg_deref",
1534 group: "correctness",
1535 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1537 module: "functions",
1542 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1549 desc: "taking a reference to satisfy the type constraints on `==`",
1554 name: "option_and_then_some",
1555 group: "complexity",
1556 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1561 name: "option_as_ref_deref",
1562 group: "complexity",
1563 desc: "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`",
1568 name: "option_env_unwrap",
1569 group: "correctness",
1570 desc: "using `option_env!(...).unwrap()` to get environment variable",
1572 module: "option_env_unwrap",
1575 name: "option_expect_used",
1576 group: "restriction",
1577 desc: "using `Option.expect()`, which might be better handled",
1582 name: "option_map_or_none",
1584 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1589 name: "option_map_unit_fn",
1590 group: "complexity",
1591 desc: "using `option.map(f)`, where `f` is a function or closure that returns `()`",
1593 module: "map_unit_fn",
1596 name: "option_map_unwrap_or",
1598 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1603 name: "option_map_unwrap_or_else",
1605 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1610 name: "option_option",
1612 desc: "usage of `Option<Option<T>>`",
1617 name: "option_unwrap_used",
1618 group: "restriction",
1619 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
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_expect_used",
1863 group: "restriction",
1864 desc: "using `Result.expect()`, which might be better handled",
1869 name: "result_map_or_into_option",
1871 desc: "using `Result.map_or(None, Some)`, which is more succinctly expressed as `ok()`",
1876 name: "result_map_unit_fn",
1877 group: "complexity",
1878 desc: "using `result.map(f)`, where `f` is a function or closure that returns `()`",
1880 module: "map_unit_fn",
1883 name: "result_map_unwrap_or_else",
1885 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.map_or_else(g, f)`",
1890 name: "result_unwrap_used",
1891 group: "restriction",
1892 desc: "using `Result.unwrap()`, which might be better handled",
1897 name: "reverse_range_loop",
1898 group: "correctness",
1899 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1904 name: "same_functions_in_if_condition",
1906 desc: "consecutive `if`s with the same function call",
1911 name: "search_is_some",
1912 group: "complexity",
1913 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1918 name: "serde_api_misuse",
1919 group: "correctness",
1920 desc: "various things that will negatively affect your serde experience",
1922 module: "serde_api",
1925 name: "shadow_reuse",
1926 group: "restriction",
1927 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1932 name: "shadow_same",
1933 group: "restriction",
1934 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1939 name: "shadow_unrelated",
1941 desc: "rebinding a name without even using the original value",
1946 name: "short_circuit_statement",
1947 group: "complexity",
1948 desc: "using a short circuit boolean condition as a statement",
1953 name: "should_implement_trait",
1955 desc: "defining a method that should be implementing a std trait",
1960 name: "similar_names",
1962 desc: "similarly named items and bindings",
1964 module: "non_expressive_names",
1967 name: "single_char_pattern",
1969 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1974 name: "single_component_path_imports",
1976 desc: "imports with single component path are redundant",
1978 module: "single_component_path_imports",
1981 name: "single_match",
1983 desc: "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1988 name: "single_match_else",
1990 desc: "a `match` statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1995 name: "skip_while_next",
1996 group: "complexity",
1997 desc: "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`",
2002 name: "slow_vector_initialization",
2004 desc: "slow vector initialization",
2006 module: "slow_vector_initialization",
2010 group: "restriction",
2011 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
2016 name: "string_add_assign",
2018 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
2023 name: "string_extend_chars",
2025 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
2030 name: "string_lit_as_bytes",
2032 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
2037 name: "struct_excessive_bools",
2039 desc: "using too many bools in a struct",
2041 module: "excessive_bools",
2044 name: "suboptimal_flops",
2046 desc: "usage of sub-optimal floating point operations",
2048 module: "floating_point_arithmetic",
2051 name: "suspicious_arithmetic_impl",
2052 group: "correctness",
2053 desc: "suspicious use of operators in impl of arithmetic trait",
2055 module: "suspicious_trait_impl",
2058 name: "suspicious_assignment_formatting",
2060 desc: "suspicious formatting of `*=`, `-=` or `!=`",
2062 module: "formatting",
2065 name: "suspicious_else_formatting",
2067 desc: "suspicious formatting of `else`",
2069 module: "formatting",
2072 name: "suspicious_map",
2073 group: "complexity",
2074 desc: "suspicious usage of map",
2079 name: "suspicious_op_assign_impl",
2080 group: "correctness",
2081 desc: "suspicious use of operators in impl of OpAssign trait",
2083 module: "suspicious_trait_impl",
2086 name: "suspicious_unary_op_formatting",
2088 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
2090 module: "formatting",
2093 name: "tabs_in_doc_comments",
2095 desc: "using tabs in doc comments is not recommended",
2097 module: "tabs_in_doc_comments",
2100 name: "temporary_assignment",
2101 group: "complexity",
2102 desc: "assignments to temporaries",
2104 module: "temporary_assignment",
2107 name: "temporary_cstring_as_ptr",
2108 group: "correctness",
2109 desc: "getting the inner pointer of a temporary `CString`",
2114 name: "to_digit_is_some",
2116 desc: "`char.is_digit()` is clearer",
2118 module: "to_digit_is_some",
2122 group: "restriction",
2123 desc: "`todo!` should not be present in production code",
2125 module: "panic_unimplemented",
2128 name: "too_many_arguments",
2129 group: "complexity",
2130 desc: "functions with too many arguments",
2132 module: "functions",
2135 name: "too_many_lines",
2137 desc: "functions with too many lines",
2139 module: "functions",
2142 name: "toplevel_ref_arg",
2144 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
2149 name: "transmute_bytes_to_str",
2150 group: "complexity",
2151 desc: "transmutes from a `&[u8]` to a `&str`",
2153 module: "transmute",
2156 name: "transmute_float_to_int",
2157 group: "complexity",
2158 desc: "transmutes from a float to an integer",
2160 module: "transmute",
2163 name: "transmute_int_to_bool",
2164 group: "complexity",
2165 desc: "transmutes from an integer to a `bool`",
2167 module: "transmute",
2170 name: "transmute_int_to_char",
2171 group: "complexity",
2172 desc: "transmutes from an integer to a `char`",
2174 module: "transmute",
2177 name: "transmute_int_to_float",
2178 group: "complexity",
2179 desc: "transmutes from an integer to a float",
2181 module: "transmute",
2184 name: "transmute_ptr_to_ptr",
2185 group: "complexity",
2186 desc: "transmutes from a pointer to a pointer / a reference to a reference",
2188 module: "transmute",
2191 name: "transmute_ptr_to_ref",
2192 group: "complexity",
2193 desc: "transmutes from a pointer to a reference type",
2195 module: "transmute",
2198 name: "transmuting_null",
2199 group: "correctness",
2200 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
2202 module: "transmuting_null",
2205 name: "trivial_regex",
2207 desc: "trivial regular expressions",
2212 name: "trivially_copy_pass_by_ref",
2214 desc: "functions taking small copyable arguments by reference",
2216 module: "trivially_copy_pass_by_ref",
2221 desc: "return errors explicitly rather than hiding them behind a `?`",
2226 name: "type_complexity",
2227 group: "complexity",
2228 desc: "usage of very complex types that might be better factored into `type` definitions",
2233 name: "type_repetition_in_bounds",
2235 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2237 module: "trait_bounds",
2240 name: "unicode_not_nfc",
2242 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2247 name: "unimplemented",
2248 group: "restriction",
2249 desc: "`unimplemented!` should not be present in production code",
2251 module: "panic_unimplemented",
2254 name: "uninit_assumed_init",
2255 group: "correctness",
2256 desc: "`MaybeUninit::uninit().assume_init()`",
2262 group: "complexity",
2263 desc: "passing unit to a function",
2269 group: "correctness",
2270 desc: "comparing unit values",
2275 name: "unknown_clippy_lints",
2277 desc: "unknown_lints for scoped Clippy lints",
2282 name: "unnecessary_cast",
2283 group: "complexity",
2284 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2289 name: "unnecessary_filter_map",
2290 group: "complexity",
2291 desc: "using `filter_map` when a more succinct alternative exists",
2296 name: "unnecessary_fold",
2298 desc: "using `fold` when a more succinct alternative exists",
2303 name: "unnecessary_mut_passed",
2305 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2307 module: "mut_reference",
2310 name: "unnecessary_operation",
2311 group: "complexity",
2312 desc: "outer expressions with no effect",
2314 module: "no_effect",
2317 name: "unnecessary_unwrap",
2318 group: "complexity",
2319 desc: "checks for calls of `unwrap[_err]()` that cannot fail",
2324 name: "unneeded_field_pattern",
2325 group: "restriction",
2326 desc: "struct fields bound to a wildcard instead of using `..`",
2328 module: "misc_early",
2331 name: "unneeded_wildcard_pattern",
2332 group: "complexity",
2333 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2335 module: "misc_early",
2338 name: "unreachable",
2339 group: "restriction",
2340 desc: "`unreachable!` should not be present in production code",
2342 module: "panic_unimplemented",
2345 name: "unreadable_literal",
2347 desc: "long integer literal without underscores",
2349 module: "literal_representation",
2352 name: "unsafe_derive_deserialize",
2354 desc: "deriving `serde::Deserialize` on a type that has methods using `unsafe`",
2359 name: "unsafe_removed_from_name",
2361 desc: "`unsafe` removed from API names on import",
2363 module: "unsafe_removed_from_name",
2366 name: "unseparated_literal_suffix",
2368 desc: "literals whose suffix is not separated by an underscore",
2370 module: "misc_early",
2373 name: "unsound_collection_transmute",
2374 group: "correctness",
2375 desc: "transmute between collections of layout-incompatible types",
2377 module: "transmute",
2380 name: "unused_io_amount",
2381 group: "correctness",
2382 desc: "unused written/read amount",
2384 module: "unused_io_amount",
2387 name: "unused_self",
2389 desc: "methods that contain a `self` argument but don\'t use it",
2391 module: "unused_self",
2394 name: "unused_unit",
2396 desc: "needless unit expression",
2402 group: "restriction",
2403 desc: "use of `Debug`-based formatting",
2410 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2415 name: "used_underscore_binding",
2417 desc: "using a binding which is prefixed with an underscore",
2422 name: "useless_asref",
2423 group: "complexity",
2424 desc: "using `as_ref` where the types before and after the call are the same",
2429 name: "useless_attribute",
2430 group: "correctness",
2431 desc: "use of lint attributes on `extern crate` items",
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: "verbose_bit_mask",
2473 desc: "expressions where a bit mask is less readable than the corresponding method call",
2478 name: "verbose_file_reads",
2479 group: "restriction",
2480 desc: "use of `File::read_to_end` or `File::read_to_string`",
2482 module: "verbose_file_reads",
2485 name: "vtable_address_comparisons",
2486 group: "correctness",
2487 desc: "comparison with an address of a trait vtable",
2489 module: "unnamed_address",
2492 name: "while_immutable_condition",
2493 group: "correctness",
2494 desc: "variables used within while expression are not mutated in the body",
2499 name: "while_let_loop",
2500 group: "complexity",
2501 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2506 name: "while_let_on_iterator",
2508 desc: "using a while-let loop instead of a for loop on an iterator",
2513 name: "wildcard_dependencies",
2515 desc: "wildcard dependencies being used",
2517 module: "wildcard_dependencies",
2520 name: "wildcard_enum_match_arm",
2521 group: "restriction",
2522 desc: "a wildcard enum match arm using `_`",
2527 name: "wildcard_imports",
2529 desc: "lint `use _::*` statements",
2531 module: "wildcard_imports",
2534 name: "wildcard_in_or_patterns",
2535 group: "complexity",
2536 desc: "a wildcard pattern used with others patterns in same match arm",
2541 name: "write_literal",
2543 desc: "writing a literal with a format string",
2548 name: "write_with_newline",
2550 desc: "using `write!()` with a format string that ends in a single newline",
2555 name: "writeln_empty_string",
2557 desc: "using `writeln!(buf, \"\")` with an empty string",
2562 name: "wrong_pub_self_convention",
2563 group: "restriction",
2564 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2569 name: "wrong_self_convention",
2571 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2576 name: "wrong_transmute",
2577 group: "correctness",
2578 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2580 module: "transmute",
2583 name: "zero_divided_by_zero",
2584 group: "complexity",
2585 desc: "usage of `0.0 / 0.0` to obtain NaN instead of `f32::NAN` or `f64::NAN`",
2587 module: "zero_div_zero",
2590 name: "zero_prefixed_literal",
2591 group: "complexity",
2592 desc: "integer literals starting with `0`",
2594 module: "misc_early",
2599 desc: "using `0 as *{const, mut} T`",
2604 name: "zero_width_space",
2605 group: "correctness",
2606 desc: "using a zero-width space in a string literal, which is confusing",
2612 group: "correctness",
2613 desc: "Check for offset calculations on raw pointers to zero-sized types",
2618 // end lint list, do not remove this comment, it’s used in `update_lints`