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",
58 desc: "expressions of the form `_ & mask == select` that will only ever return `true` or `false`",
63 name: "blacklisted_name",
65 desc: "usage of a blacklisted/placeholder name",
67 module: "blacklisted_name",
70 name: "block_in_if_condition_expr",
72 desc: "braces that can be eliminated in conditions, e.g., `if { true } ...`",
74 module: "block_in_if_condition",
77 name: "block_in_if_condition_stmt",
79 desc: "complex blocks in conditions, e.g., `if { let x = true; x } ...`",
81 module: "block_in_if_condition",
84 name: "bool_comparison",
86 desc: "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`",
88 module: "needless_bool",
91 name: "borrow_interior_mutable_const",
93 desc: "referencing `const` with interior mutability",
95 module: "non_copy_const",
100 desc: "a borrow of a boxed type",
107 desc: "usage of `Box<Vec<T>>`, vector elements are already on the heap",
114 desc: "using `Box<T>` where unnecessary",
119 name: "builtin_type_shadow",
121 desc: "shadowing a builtin type",
123 module: "misc_early",
126 name: "cargo_common_metadata",
128 desc: "common metadata is defined in `Cargo.toml`",
130 module: "cargo_common_metadata",
133 name: "cast_lossless",
135 desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
140 name: "cast_possible_truncation",
142 desc: "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`",
147 name: "cast_possible_wrap",
149 desc: "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`",
154 name: "cast_precision_loss",
156 desc: "casts that cause loss of precision, e.g., `x as f32` where `x: u64`",
161 name: "cast_ptr_alignment",
162 group: "correctness",
163 desc: "cast from a pointer to a more-strictly-aligned pointer",
168 name: "cast_ref_to_mut",
169 group: "correctness",
170 desc: "a cast of reference to a mutable pointer",
175 name: "cast_sign_loss",
177 desc: "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`",
182 name: "char_lit_as_u8",
184 desc: "casting a character literal to `u8` truncates",
189 name: "chars_last_cmp",
191 desc: "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char",
196 name: "chars_next_cmp",
198 desc: "using `.chars().next()` to check if a string starts with a char",
203 name: "checked_conversions",
205 desc: "`try_from` could replace manual bounds checking when casting",
207 module: "checked_conversions",
210 name: "clone_double_ref",
211 group: "correctness",
212 desc: "using `clone` on `&&T`",
217 name: "clone_on_copy",
219 desc: "using `clone` on a `Copy` type",
224 name: "clone_on_ref_ptr",
225 group: "restriction",
226 desc: "using \'clone\' on a ref-counted pointer",
232 group: "correctness",
233 desc: "comparisons to `NAN`, which will always return false, probably not intended",
240 desc: "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead.",
247 desc: "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`",
252 name: "cognitive_complexity",
254 desc: "functions that should be split up into multiple functions",
256 module: "cognitive_complexity",
259 name: "collapsible_if",
261 desc: "`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)",
263 module: "collapsible_if",
266 name: "comparison_chain",
268 desc: "`if`s that can be rewritten with `match` and `cmp`",
270 module: "comparison_chain",
273 name: "copy_iterator",
275 desc: "implementing `Iterator` on a `Copy` type",
277 module: "copy_iterator",
280 name: "crosspointer_transmute",
282 desc: "transmutes that have to or from types that are a pointer to the other",
288 group: "restriction",
289 desc: "`dbg!` macro is intended as a debugging tool",
294 name: "debug_assert_with_mut_call",
296 desc: "mutable arguments in `debug_assert{,_ne,_eq}!`",
298 module: "mutable_debug_assertion",
301 name: "decimal_literal_representation",
302 group: "restriction",
303 desc: "using decimal representation when hexadecimal would be better",
305 module: "literal_representation",
308 name: "declare_interior_mutable_const",
309 group: "correctness",
310 desc: "declaring `const` with interior mutability",
312 module: "non_copy_const",
315 name: "default_trait_access",
317 desc: "checks for literal calls to `Default::default()`",
319 module: "default_trait_access",
322 name: "deprecated_cfg_attr",
324 desc: "usage of `cfg_attr(rustfmt)` instead of tool attributes",
329 name: "deprecated_semver",
330 group: "correctness",
331 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
336 name: "deref_addrof",
338 desc: "use of `*&` or `*&mut` in an expression",
343 name: "derive_hash_xor_eq",
344 group: "correctness",
345 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
350 name: "diverging_sub_expression",
352 desc: "whether an expression contains a diverging sub expression",
354 module: "eval_order_dependence",
357 name: "doc_markdown",
359 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
364 name: "double_comparisons",
366 desc: "unnecessary double comparisons that can be simplified",
368 module: "double_comparison",
371 name: "double_must_use",
373 desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method",
380 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
382 module: "misc_early",
385 name: "double_parens",
387 desc: "Warn on unnecessary double parentheses",
389 module: "double_parens",
393 group: "correctness",
394 desc: "Bounds of the form `T: Drop` are useless",
396 module: "drop_bounds",
400 group: "correctness",
401 desc: "calls to `std::mem::drop` with a value that implements Copy",
403 module: "drop_forget_ref",
407 group: "correctness",
408 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
410 module: "drop_forget_ref",
413 name: "duplicate_underscore_argument",
415 desc: "function arguments having names which only differ by an underscore",
417 module: "misc_early",
420 name: "duration_subsec",
422 desc: "checks for calculation of subsecond microseconds or milliseconds",
424 module: "duration_subsec",
427 name: "else_if_without_else",
428 group: "restriction",
429 desc: "`if` expression with an `else if`, but without a final `else` branch",
431 module: "else_if_without_else",
436 desc: "enum with no variants",
438 module: "empty_enum",
441 name: "empty_line_after_outer_attr",
443 desc: "empty line after outer attribute",
450 desc: "empty `loop {}`, which should block or sleep",
455 name: "enum_clike_unportable_variant",
456 group: "correctness",
457 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
459 module: "enum_clike",
462 name: "enum_glob_use",
464 desc: "use items that import all variants of an enum",
466 module: "wildcard_imports",
469 name: "enum_variant_names",
471 desc: "enums where all variants share a prefix/postfix",
473 module: "enum_variants",
477 group: "correctness",
478 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
484 group: "correctness",
485 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
487 module: "erasing_op",
490 name: "eval_order_dependence",
492 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
494 module: "eval_order_dependence",
497 name: "excessive_precision",
499 desc: "excessive precision for float literal",
501 module: "float_literal",
505 group: "restriction",
506 desc: "`std::process::exit` is called, terminating the program",
511 name: "expect_fun_call",
513 desc: "using any `expect` method with a function call",
518 name: "expl_impl_clone_on_copy",
520 desc: "implementing `Clone` explicitly on `Copy` types",
525 name: "explicit_counter_loop",
527 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
532 name: "explicit_into_iter_loop",
534 desc: "for-looping over `_.into_iter()` when `_` would do",
539 name: "explicit_iter_loop",
541 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
546 name: "explicit_write",
548 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
550 module: "explicit_write",
553 name: "extra_unused_lifetimes",
555 desc: "unused lifetimes in function definitions",
560 name: "fallible_impl_from",
562 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
564 module: "fallible_impl_from",
567 name: "filetype_is_file",
568 group: "restriction",
569 desc: "`FileType::is_file` is not recommended to test for readable file type",
576 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
581 name: "filter_map_next",
583 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
590 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
597 desc: "using a combination of `find` and `map` can usually be written as a single method call",
602 name: "flat_map_identity",
604 desc: "call to `flat_map` where `flatten` is sufficient",
609 name: "float_arithmetic",
610 group: "restriction",
611 desc: "any floating-point arithmetic statement",
613 module: "arithmetic",
617 group: "correctness",
618 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
623 name: "float_cmp_const",
624 group: "restriction",
625 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
630 name: "fn_address_comparisons",
631 group: "correctness",
632 desc: "comparison with an address of a function item",
634 module: "unnamed_address",
637 name: "fn_params_excessive_bools",
639 desc: "using too many bools in function parameters",
641 module: "excessive_bools",
644 name: "fn_to_numeric_cast",
646 desc: "casting a function pointer to a numeric type other than usize",
651 name: "fn_to_numeric_cast_with_truncation",
653 desc: "casting a function pointer to a numeric type not wide enough to store the address",
660 desc: "looping on a map using `iter` when `keys` or `values` would do",
665 name: "for_loop_over_option",
666 group: "correctness",
667 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
672 name: "for_loop_over_result",
673 group: "correctness",
674 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
680 group: "correctness",
681 desc: "calls to `std::mem::forget` with a value that implements Copy",
683 module: "drop_forget_ref",
687 group: "correctness",
688 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
690 module: "drop_forget_ref",
693 name: "get_last_with_len",
695 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
697 module: "get_last_with_len",
701 group: "restriction",
702 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
707 name: "identity_conversion",
709 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
711 module: "identity_conversion",
716 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
718 module: "identity_op",
721 name: "if_let_some_result",
723 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
725 module: "if_let_some_result",
730 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
732 module: "if_not_else",
735 name: "if_same_then_else",
736 group: "correctness",
737 desc: "`if` with the same `then` and `else` blocks",
742 name: "ifs_same_cond",
743 group: "correctness",
744 desc: "consecutive `if`s with the same condition",
749 name: "implicit_hasher",
751 desc: "missing generalization over different hashers",
756 name: "implicit_return",
757 group: "restriction",
758 desc: "use a return statement like `return expr` instead of an expression",
760 module: "implicit_return",
763 name: "imprecise_flops",
765 desc: "usage of imprecise floating point operations",
767 module: "floating_point_arithmetic",
770 name: "inconsistent_digit_grouping",
772 desc: "integer literals with digits grouped inconsistently",
774 module: "literal_representation",
777 name: "indexing_slicing",
778 group: "restriction",
779 desc: "indexing/slicing usage",
781 module: "indexing_slicing",
784 name: "ineffective_bit_mask",
785 group: "correctness",
786 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
791 name: "inefficient_to_string",
793 desc: "using `to_string` on `&&T` where `T: ToString`",
798 name: "infallible_destructuring_match",
800 desc: "a `match` statement with a single infallible arm instead of a `let`",
805 name: "infinite_iter",
806 group: "correctness",
807 desc: "infinite iteration",
809 module: "infinite_iter",
812 name: "inherent_to_string",
814 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
816 module: "inherent_to_string",
819 name: "inherent_to_string_shadow_display",
820 group: "correctness",
821 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait",
823 module: "inherent_to_string",
826 name: "inline_always",
828 desc: "use of `#[inline(always)]`",
833 name: "inline_fn_without_body",
834 group: "correctness",
835 desc: "use of `#[inline]` on trait methods without bodies",
837 module: "inline_fn_without_body",
840 name: "int_plus_one",
842 desc: "instead of using `x >= y + 1`, use `x > y`",
844 module: "int_plus_one",
847 name: "integer_arithmetic",
848 group: "restriction",
849 desc: "any integer arithmetic statement",
851 module: "arithmetic",
854 name: "integer_division",
855 group: "restriction",
856 desc: "integer division may cause loss of precision",
858 module: "integer_division",
861 name: "into_iter_on_ref",
863 desc: "using `.into_iter()` on a reference",
868 name: "invalid_atomic_ordering",
869 group: "correctness",
870 desc: "usage of invalid atomic ordering in atomic loads/stores and memory fences",
872 module: "atomic_ordering",
875 name: "invalid_regex",
876 group: "correctness",
877 desc: "invalid regular expressions",
882 name: "invalid_upcast_comparisons",
884 desc: "a comparison involving an upcast which is always true or false",
889 name: "items_after_statements",
891 desc: "blocks where an item comes after a statement",
893 module: "items_after_statements",
896 name: "iter_cloned_collect",
898 desc: "using `.cloned().collect()` on slice to create a `Vec`",
903 name: "iter_next_loop",
904 group: "correctness",
905 desc: "for-looping over `_.next()` which is probably not intended",
912 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
917 name: "iter_nth_zero",
919 desc: "replace `iter.nth(0)` with `iter.next()`",
924 name: "iter_skip_next",
926 desc: "using `.skip(x).next()` on an iterator",
931 name: "iterator_step_by_zero",
932 group: "correctness",
933 desc: "using `Iterator::step_by(0)`, which will panic at runtime",
938 name: "just_underscores_and_digits",
940 desc: "unclear name",
942 module: "non_expressive_names",
945 name: "large_digit_groups",
947 desc: "grouping digits into groups that are too large",
949 module: "literal_representation",
952 name: "large_enum_variant",
954 desc: "large size difference between variants on an enum",
956 module: "large_enum_variant",
959 name: "large_stack_arrays",
961 desc: "allocating large arrays on stack may cause stack overflow",
963 module: "large_stack_arrays",
966 name: "len_without_is_empty",
968 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
975 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
980 name: "let_and_return",
982 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
987 name: "let_underscore_lock",
988 group: "correctness",
989 desc: "non-binding let on a synchronization lock",
991 module: "let_underscore",
994 name: "let_underscore_must_use",
995 group: "restriction",
996 desc: "non-binding let on a `#[must_use]` expression",
998 module: "let_underscore",
1001 name: "let_unit_value",
1003 desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
1010 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`",
1016 group: "correctness",
1017 desc: "boolean expressions that contain terminals which can be eliminated",
1022 name: "lossy_float_literal",
1023 group: "restriction",
1024 desc: "lossy whole number float literals",
1026 module: "float_literal",
1029 name: "macro_use_imports",
1031 desc: "#[macro_use] is no longer needed",
1033 module: "macro_use",
1036 name: "main_recursion",
1038 desc: "recursion using the entrypoint",
1040 module: "main_recursion",
1043 name: "manual_memcpy",
1045 desc: "manually copying items between slices",
1050 name: "manual_saturating_arithmetic",
1052 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
1057 name: "manual_swap",
1058 group: "complexity",
1059 desc: "manual swap of two variables",
1064 name: "many_single_char_names",
1066 desc: "too many single character bindings",
1068 module: "non_expressive_names",
1073 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1075 module: "map_clone",
1080 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1085 name: "map_flatten",
1087 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1092 name: "match_as_ref",
1093 group: "complexity",
1094 desc: "a `match` on an Option value instead of using `as_ref()` or `as_mut`",
1101 desc: "a `match` on a boolean expression instead of an `if..else` block",
1106 name: "match_overlapping_arm",
1108 desc: "a `match` with overlapping arms",
1113 name: "match_ref_pats",
1115 desc: "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1120 name: "match_same_arms",
1122 desc: "`match` with identical arm bodies",
1127 name: "match_single_binding",
1128 group: "complexity",
1129 desc: "a match with a single binding instead of using `let` statement",
1134 name: "match_wild_err_arm",
1136 desc: "a `match` with `Err(_)` arm and take drastic actions",
1141 name: "maybe_infinite_iter",
1143 desc: "possible infinite iteration",
1145 module: "infinite_iter",
1148 name: "mem_discriminant_non_enum",
1149 group: "correctness",
1150 desc: "calling `mem::descriminant` on non-enum type",
1152 module: "mem_discriminant",
1156 group: "restriction",
1157 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1159 module: "mem_forget",
1162 name: "mem_replace_option_with_none",
1164 desc: "replacing an `Option` with `None` instead of `take()`",
1166 module: "mem_replace",
1169 name: "mem_replace_with_default",
1171 desc: "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`",
1173 module: "mem_replace",
1176 name: "mem_replace_with_uninit",
1177 group: "correctness",
1178 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1180 module: "mem_replace",
1184 group: "correctness",
1185 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1190 name: "misrefactored_assign_op",
1191 group: "complexity",
1192 desc: "having a variable on both sides of an assign op",
1194 module: "assign_ops",
1197 name: "missing_const_for_fn",
1199 desc: "Lint functions definitions that could be made `const fn`",
1201 module: "missing_const_for_fn",
1204 name: "missing_docs_in_private_items",
1205 group: "restriction",
1206 desc: "detects missing documentation for public and private members",
1208 module: "missing_doc",
1211 name: "missing_errors_doc",
1213 desc: "`pub fn` returns `Result` without `# Errors` in doc comment",
1218 name: "missing_inline_in_public_items",
1219 group: "restriction",
1220 desc: "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)",
1222 module: "missing_inline",
1225 name: "missing_safety_doc",
1227 desc: "`pub unsafe fn` without `# Safety` docs",
1232 name: "mistyped_literal_suffixes",
1233 group: "correctness",
1234 desc: "mistyped literal suffix",
1236 module: "literal_representation",
1239 name: "mixed_case_hex_literals",
1241 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1243 module: "misc_early",
1246 name: "module_inception",
1248 desc: "modules that have the same name as their parent module",
1250 module: "enum_variants",
1253 name: "module_name_repetitions",
1255 desc: "type names prefixed/postfixed with their containing module\'s name",
1257 module: "enum_variants",
1260 name: "modulo_arithmetic",
1261 group: "restriction",
1262 desc: "any modulo arithmetic statement",
1264 module: "modulo_arithmetic",
1268 group: "correctness",
1269 desc: "taking a number modulo 1, which always returns 0",
1274 name: "multiple_crate_versions",
1276 desc: "multiple versions of the same crate being used",
1278 module: "multiple_crate_versions",
1281 name: "multiple_inherent_impl",
1282 group: "restriction",
1283 desc: "Multiple inherent impl that could be grouped",
1285 module: "inherent_impl",
1288 name: "must_use_candidate",
1290 desc: "function or method that could take a `#[must_use]` attribute",
1292 module: "functions",
1295 name: "must_use_unit",
1297 desc: "`#[must_use]` attribute on a unit-returning function / method",
1299 module: "functions",
1302 name: "mut_from_ref",
1303 group: "correctness",
1304 desc: "fns that create mutable refs from immutable ref args",
1311 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1316 name: "mut_range_bound",
1317 group: "complexity",
1318 desc: "for loop over a range where one of the bounds is a mutable variable",
1323 name: "mutable_key_type",
1324 group: "correctness",
1325 desc: "Check for mutable `Map`/`Set` key type",
1330 name: "mutex_atomic",
1332 desc: "using a mutex where an atomic value could be used instead",
1334 module: "mutex_atomic",
1337 name: "mutex_integer",
1339 desc: "using a mutex for an integer type",
1341 module: "mutex_atomic",
1344 name: "naive_bytecount",
1346 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1348 module: "bytecount",
1351 name: "needless_bool",
1352 group: "complexity",
1353 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1355 module: "needless_bool",
1358 name: "needless_borrow",
1360 desc: "taking a reference that is going to be automatically dereferenced",
1362 module: "needless_borrow",
1365 name: "needless_borrowed_reference",
1366 group: "complexity",
1367 desc: "taking a needless borrowed reference",
1369 module: "needless_borrowed_ref",
1372 name: "needless_collect",
1374 desc: "collecting an iterator when collect is not needed",
1379 name: "needless_continue",
1381 desc: "`continue` statements that can be replaced by a rearrangement of code",
1383 module: "needless_continue",
1386 name: "needless_doctest_main",
1388 desc: "presence of `fn main() {` in code examples",
1393 name: "needless_lifetimes",
1394 group: "complexity",
1395 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1397 module: "lifetimes",
1400 name: "needless_pass_by_value",
1402 desc: "functions taking arguments by value, but not consuming them in its body",
1404 module: "needless_pass_by_value",
1407 name: "needless_range_loop",
1409 desc: "for-looping over a range of indices where an iterator over items would do",
1414 name: "needless_return",
1416 desc: "using a return statement like `return expr;` where an expression would suffice",
1421 name: "needless_update",
1422 group: "complexity",
1423 desc: "using `Foo { ..base }` when there are no missing fields",
1425 module: "needless_update",
1428 name: "neg_cmp_op_on_partial_ord",
1429 group: "complexity",
1430 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1432 module: "neg_cmp_op_on_partial_ord",
1435 name: "neg_multiply",
1437 desc: "multiplying integers with `-1`",
1439 module: "neg_multiply",
1443 group: "correctness",
1444 desc: "any loop that will always `break` or `return`",
1449 name: "new_ret_no_self",
1451 desc: "not returning `Self` in a `new` method",
1456 name: "new_without_default",
1458 desc: "`fn new() -> Self` method without `Default` implementation",
1460 module: "new_without_default",
1464 group: "complexity",
1465 desc: "statements with no effect",
1467 module: "no_effect",
1470 name: "non_ascii_literal",
1472 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1477 name: "nonminimal_bool",
1478 group: "complexity",
1479 desc: "boolean expressions that can be written more concisely",
1484 name: "nonsensical_open_options",
1485 group: "correctness",
1486 desc: "nonsensical combination of options for opening a file",
1488 module: "open_options",
1491 name: "not_unsafe_ptr_arg_deref",
1492 group: "correctness",
1493 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1495 module: "functions",
1500 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1507 desc: "taking a reference to satisfy the type constraints on `==`",
1512 name: "option_and_then_some",
1513 group: "complexity",
1514 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1519 name: "option_as_ref_deref",
1520 group: "complexity",
1521 desc: "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`",
1526 name: "option_env_unwrap",
1527 group: "correctness",
1528 desc: "using `option_env!(...).unwrap()` to get environment variable",
1530 module: "option_env_unwrap",
1533 name: "option_expect_used",
1534 group: "restriction",
1535 desc: "using `Option.expect()`, which might be better handled",
1540 name: "option_map_or_none",
1542 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1547 name: "option_map_unit_fn",
1548 group: "complexity",
1549 desc: "using `option.map(f)`, where `f` is a function or closure that returns `()`",
1551 module: "map_unit_fn",
1554 name: "option_map_unwrap_or",
1556 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1561 name: "option_map_unwrap_or_else",
1563 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1568 name: "option_option",
1570 desc: "usage of `Option<Option<T>>`",
1575 name: "option_unwrap_used",
1576 group: "restriction",
1577 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1582 name: "or_fun_call",
1584 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1589 name: "out_of_bounds_indexing",
1590 group: "correctness",
1591 desc: "out of bounds constant indexing",
1593 module: "indexing_slicing",
1596 name: "overflow_check_conditional",
1597 group: "complexity",
1598 desc: "overflow checks inspired by C which are likely to panic",
1600 module: "overflow_check_conditional",
1604 group: "restriction",
1605 desc: "usage of the `panic!` macro",
1607 module: "panic_unimplemented",
1610 name: "panic_params",
1612 desc: "missing parameters in `panic!` calls",
1614 module: "panic_unimplemented",
1617 name: "panicking_unwrap",
1618 group: "correctness",
1619 desc: "checks for calls of `unwrap[_err]()` that will always fail",
1624 name: "partialeq_ne_impl",
1625 group: "complexity",
1626 desc: "re-implementing `PartialEq::ne`",
1628 module: "partialeq_ne_impl",
1631 name: "path_buf_push_overwrite",
1633 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1635 module: "path_buf_push_overwrite",
1638 name: "possible_missing_comma",
1639 group: "correctness",
1640 desc: "possible missing comma in array",
1642 module: "formatting",
1646 group: "complexity",
1647 desc: "operations where precedence may be unclear",
1649 module: "precedence",
1652 name: "print_literal",
1654 desc: "printing a literal with a format string",
1659 name: "print_stdout",
1660 group: "restriction",
1661 desc: "printing on stdout",
1666 name: "print_with_newline",
1668 desc: "using `print!()` with a format string that ends in a single newline",
1673 name: "println_empty_string",
1675 desc: "using `println!(\"\")` with an empty string",
1682 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1687 name: "ptr_offset_with_cast",
1688 group: "complexity",
1689 desc: "unneeded pointer offset cast",
1691 module: "ptr_offset_with_cast",
1694 name: "pub_enum_variant_names",
1696 desc: "enums where all variants share a prefix/postfix",
1698 module: "enum_variants",
1701 name: "question_mark",
1703 desc: "checks for expressions that could be replaced by the question mark operator",
1705 module: "question_mark",
1708 name: "range_minus_one",
1709 group: "complexity",
1710 desc: "`x..=(y-1)` reads better as `x..y`",
1715 name: "range_plus_one",
1717 desc: "`x..(y+1)` reads better as `x..=y`",
1722 name: "range_zip_with_len",
1723 group: "complexity",
1724 desc: "zipping iterator with a range when `enumerate()` would do",
1729 name: "redundant_allocation",
1731 desc: "redundant allocation",
1736 name: "redundant_clone",
1738 desc: "`clone()` of an owned value that is going to be dropped immediately",
1740 module: "redundant_clone",
1743 name: "redundant_closure",
1745 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1747 module: "eta_reduction",
1750 name: "redundant_closure_call",
1751 group: "complexity",
1752 desc: "throwaway closures called in the expression they are defined",
1754 module: "misc_early",
1757 name: "redundant_closure_for_method_calls",
1759 desc: "redundant closures for method calls",
1761 module: "eta_reduction",
1764 name: "redundant_field_names",
1766 desc: "checks for fields in struct literals where shorthands could be used",
1768 module: "redundant_field_names",
1771 name: "redundant_pattern",
1773 desc: "using `name @ _` in a pattern",
1775 module: "misc_early",
1778 name: "redundant_pattern_matching",
1780 desc: "use the proper utility function avoiding an `if let`",
1782 module: "redundant_pattern_matching",
1785 name: "redundant_pub_crate",
1787 desc: "Using `pub(crate)` visibility on items that are not crate visible due to the visibility of the module that contains them.",
1789 module: "redundant_pub_crate",
1792 name: "redundant_static_lifetimes",
1794 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1796 module: "redundant_static_lifetimes",
1799 name: "ref_in_deref",
1800 group: "complexity",
1801 desc: "Use of reference in auto dereference expression.",
1803 module: "reference",
1806 name: "regex_macro",
1808 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1813 name: "rest_pat_in_fully_bound_structs",
1814 group: "restriction",
1815 desc: "a match on a struct that binds all fields but still uses the wildcard pattern",
1820 name: "result_expect_used",
1821 group: "restriction",
1822 desc: "using `Result.expect()`, which might be better handled",
1827 name: "result_map_or_into_option",
1829 desc: "using `Result.map_or(None, Some)`, which is more succinctly expressed as `ok()`",
1834 name: "result_map_unit_fn",
1835 group: "complexity",
1836 desc: "using `result.map(f)`, where `f` is a function or closure that returns `()`",
1838 module: "map_unit_fn",
1841 name: "result_map_unwrap_or_else",
1843 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.map_or_else(g, f)`",
1848 name: "result_unwrap_used",
1849 group: "restriction",
1850 desc: "using `Result.unwrap()`, which might be better handled",
1855 name: "reverse_range_loop",
1856 group: "correctness",
1857 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1862 name: "same_functions_in_if_condition",
1864 desc: "consecutive `if`s with the same function call",
1869 name: "search_is_some",
1870 group: "complexity",
1871 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1876 name: "serde_api_misuse",
1877 group: "correctness",
1878 desc: "various things that will negatively affect your serde experience",
1880 module: "serde_api",
1883 name: "shadow_reuse",
1884 group: "restriction",
1885 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1890 name: "shadow_same",
1891 group: "restriction",
1892 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1897 name: "shadow_unrelated",
1899 desc: "rebinding a name without even using the original value",
1904 name: "short_circuit_statement",
1905 group: "complexity",
1906 desc: "using a short circuit boolean condition as a statement",
1911 name: "should_implement_trait",
1913 desc: "defining a method that should be implementing a std trait",
1918 name: "similar_names",
1920 desc: "similarly named items and bindings",
1922 module: "non_expressive_names",
1925 name: "single_char_pattern",
1927 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1932 name: "single_component_path_imports",
1934 desc: "imports with single component path are redundant",
1936 module: "single_component_path_imports",
1939 name: "single_match",
1941 desc: "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1946 name: "single_match_else",
1948 desc: "a `match` statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1953 name: "skip_while_next",
1954 group: "complexity",
1955 desc: "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`",
1960 name: "slow_vector_initialization",
1962 desc: "slow vector initialization",
1964 module: "slow_vector_initialization",
1968 group: "restriction",
1969 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1974 name: "string_add_assign",
1976 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1981 name: "string_extend_chars",
1983 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1988 name: "string_lit_as_bytes",
1990 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1995 name: "struct_excessive_bools",
1997 desc: "using too many bools in a struct",
1999 module: "excessive_bools",
2002 name: "suboptimal_flops",
2004 desc: "usage of sub-optimal floating point operations",
2006 module: "floating_point_arithmetic",
2009 name: "suspicious_arithmetic_impl",
2010 group: "correctness",
2011 desc: "suspicious use of operators in impl of arithmetic trait",
2013 module: "suspicious_trait_impl",
2016 name: "suspicious_assignment_formatting",
2018 desc: "suspicious formatting of `*=`, `-=` or `!=`",
2020 module: "formatting",
2023 name: "suspicious_else_formatting",
2025 desc: "suspicious formatting of `else`",
2027 module: "formatting",
2030 name: "suspicious_map",
2031 group: "complexity",
2032 desc: "suspicious usage of map",
2037 name: "suspicious_op_assign_impl",
2038 group: "correctness",
2039 desc: "suspicious use of operators in impl of OpAssign trait",
2041 module: "suspicious_trait_impl",
2044 name: "suspicious_unary_op_formatting",
2046 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
2048 module: "formatting",
2051 name: "tabs_in_doc_comments",
2053 desc: "using tabs in doc comments is not recommended",
2055 module: "tabs_in_doc_comments",
2058 name: "temporary_assignment",
2059 group: "complexity",
2060 desc: "assignments to temporaries",
2062 module: "temporary_assignment",
2065 name: "temporary_cstring_as_ptr",
2066 group: "correctness",
2067 desc: "getting the inner pointer of a temporary `CString`",
2072 name: "to_digit_is_some",
2074 desc: "`char.is_digit()` is clearer",
2076 module: "to_digit_is_some",
2080 group: "restriction",
2081 desc: "`todo!` should not be present in production code",
2083 module: "panic_unimplemented",
2086 name: "too_many_arguments",
2087 group: "complexity",
2088 desc: "functions with too many arguments",
2090 module: "functions",
2093 name: "too_many_lines",
2095 desc: "functions with too many lines",
2097 module: "functions",
2100 name: "toplevel_ref_arg",
2102 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
2107 name: "transmute_bytes_to_str",
2108 group: "complexity",
2109 desc: "transmutes from a `&[u8]` to a `&str`",
2111 module: "transmute",
2114 name: "transmute_float_to_int",
2115 group: "complexity",
2116 desc: "transmutes from a float to an integer",
2118 module: "transmute",
2121 name: "transmute_int_to_bool",
2122 group: "complexity",
2123 desc: "transmutes from an integer to a `bool`",
2125 module: "transmute",
2128 name: "transmute_int_to_char",
2129 group: "complexity",
2130 desc: "transmutes from an integer to a `char`",
2132 module: "transmute",
2135 name: "transmute_int_to_float",
2136 group: "complexity",
2137 desc: "transmutes from an integer to a float",
2139 module: "transmute",
2142 name: "transmute_ptr_to_ptr",
2143 group: "complexity",
2144 desc: "transmutes from a pointer to a pointer / a reference to a reference",
2146 module: "transmute",
2149 name: "transmute_ptr_to_ref",
2150 group: "complexity",
2151 desc: "transmutes from a pointer to a reference type",
2153 module: "transmute",
2156 name: "transmuting_null",
2157 group: "correctness",
2158 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
2160 module: "transmuting_null",
2163 name: "trivial_regex",
2165 desc: "trivial regular expressions",
2170 name: "trivially_copy_pass_by_ref",
2172 desc: "functions taking small copyable arguments by reference",
2174 module: "trivially_copy_pass_by_ref",
2179 desc: "return errors explicitly rather than hiding them behind a `?`",
2184 name: "type_complexity",
2185 group: "complexity",
2186 desc: "usage of very complex types that might be better factored into `type` definitions",
2191 name: "type_repetition_in_bounds",
2193 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2195 module: "trait_bounds",
2198 name: "unicode_not_nfc",
2200 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2205 name: "unimplemented",
2206 group: "restriction",
2207 desc: "`unimplemented!` should not be present in production code",
2209 module: "panic_unimplemented",
2212 name: "uninit_assumed_init",
2213 group: "correctness",
2214 desc: "`MaybeUninit::uninit().assume_init()`",
2220 group: "complexity",
2221 desc: "passing unit to a function",
2227 group: "correctness",
2228 desc: "comparing unit values",
2233 name: "unknown_clippy_lints",
2235 desc: "unknown_lints for scoped Clippy lints",
2240 name: "unnecessary_cast",
2241 group: "complexity",
2242 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2247 name: "unnecessary_filter_map",
2248 group: "complexity",
2249 desc: "using `filter_map` when a more succinct alternative exists",
2254 name: "unnecessary_fold",
2256 desc: "using `fold` when a more succinct alternative exists",
2261 name: "unnecessary_mut_passed",
2263 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2265 module: "mut_reference",
2268 name: "unnecessary_operation",
2269 group: "complexity",
2270 desc: "outer expressions with no effect",
2272 module: "no_effect",
2275 name: "unnecessary_unwrap",
2276 group: "complexity",
2277 desc: "checks for calls of `unwrap[_err]()` that cannot fail",
2282 name: "unneeded_field_pattern",
2283 group: "restriction",
2284 desc: "struct fields bound to a wildcard instead of using `..`",
2286 module: "misc_early",
2289 name: "unneeded_wildcard_pattern",
2290 group: "complexity",
2291 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2293 module: "misc_early",
2296 name: "unreachable",
2297 group: "restriction",
2298 desc: "`unreachable!` should not be present in production code",
2300 module: "panic_unimplemented",
2303 name: "unreadable_literal",
2305 desc: "long integer literal without underscores",
2307 module: "literal_representation",
2310 name: "unsafe_removed_from_name",
2312 desc: "`unsafe` removed from API names on import",
2314 module: "unsafe_removed_from_name",
2317 name: "unseparated_literal_suffix",
2319 desc: "literals whose suffix is not separated by an underscore",
2321 module: "misc_early",
2324 name: "unsound_collection_transmute",
2325 group: "correctness",
2326 desc: "transmute between collections of layout-incompatible types",
2328 module: "transmute",
2331 name: "unused_io_amount",
2332 group: "correctness",
2333 desc: "unused written/read amount",
2335 module: "unused_io_amount",
2338 name: "unused_self",
2340 desc: "methods that contain a `self` argument but don\'t use it",
2342 module: "unused_self",
2345 name: "unused_unit",
2347 desc: "needless unit expression",
2353 group: "restriction",
2354 desc: "use of `Debug`-based formatting",
2361 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2366 name: "used_underscore_binding",
2368 desc: "using a binding which is prefixed with an underscore",
2373 name: "useless_asref",
2374 group: "complexity",
2375 desc: "using `as_ref` where the types before and after the call are the same",
2380 name: "useless_attribute",
2381 group: "correctness",
2382 desc: "use of lint attributes on `extern crate` items",
2387 name: "useless_format",
2388 group: "complexity",
2389 desc: "useless use of `format!`",
2394 name: "useless_let_if_seq",
2396 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2398 module: "let_if_seq",
2401 name: "useless_transmute",
2403 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2405 module: "transmute",
2408 name: "useless_vec",
2410 desc: "useless `vec!`",
2416 group: "complexity",
2417 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2422 name: "verbose_bit_mask",
2424 desc: "expressions where a bit mask is less readable than the corresponding method call",
2429 name: "verbose_file_reads",
2430 group: "restriction",
2431 desc: "use of `File::read_to_end` or `File::read_to_string`",
2433 module: "verbose_file_reads",
2436 name: "vtable_address_comparisons",
2437 group: "correctness",
2438 desc: "comparison with an address of a trait vtable",
2440 module: "unnamed_address",
2443 name: "while_immutable_condition",
2444 group: "correctness",
2445 desc: "variables used within while expression are not mutated in the body",
2450 name: "while_let_loop",
2451 group: "complexity",
2452 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2457 name: "while_let_on_iterator",
2459 desc: "using a while-let loop instead of a for loop on an iterator",
2464 name: "wildcard_dependencies",
2466 desc: "wildcard dependencies being used",
2468 module: "wildcard_dependencies",
2471 name: "wildcard_enum_match_arm",
2472 group: "restriction",
2473 desc: "a wildcard enum match arm using `_`",
2478 name: "wildcard_imports",
2480 desc: "lint `use _::*` statements",
2482 module: "wildcard_imports",
2485 name: "wildcard_in_or_patterns",
2486 group: "complexity",
2487 desc: "a wildcard pattern used with others patterns in same match arm",
2492 name: "write_literal",
2494 desc: "writing a literal with a format string",
2499 name: "write_with_newline",
2501 desc: "using `write!()` with a format string that ends in a single newline",
2506 name: "writeln_empty_string",
2508 desc: "using `writeln!(buf, \"\")` with an empty string",
2513 name: "wrong_pub_self_convention",
2514 group: "restriction",
2515 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2520 name: "wrong_self_convention",
2522 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2527 name: "wrong_transmute",
2528 group: "correctness",
2529 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2531 module: "transmute",
2534 name: "zero_divided_by_zero",
2535 group: "complexity",
2536 desc: "usage of `0.0 / 0.0` to obtain NaN instead of `f32::NAN` or `f64::NAN`",
2538 module: "zero_div_zero",
2541 name: "zero_prefixed_literal",
2542 group: "complexity",
2543 desc: "integer literals starting with `0`",
2545 module: "misc_early",
2550 desc: "using `0 as *{const, mut} T`",
2555 name: "zero_width_space",
2556 group: "correctness",
2557 desc: "using a zero-width space in a string literal, which is confusing",
2563 group: "correctness",
2564 desc: "Check for offset calculations on raw pointers to zero-sized types",
2569 // end lint list, do not remove this comment, it’s used in `update_lints`