1 //! This file is managed by `util/dev update_lints`. Do not edit.
6 pub use lint::LINT_LEVELS;
8 // begin lint list, do not remove this comment, it’s used in `update_lints`
9 pub const ALL_LINTS: [Lint; 345] = [
11 name: "absurd_extreme_comparisons",
13 desc: "a comparison with a maximum or minimum value that is always true or false",
18 name: "almost_swapped",
20 desc: "`foo = bar; bar = foo` sequence",
25 name: "approx_constant",
27 desc: "the approximate of a known float constant (in `std::fXX::consts`)",
29 module: "approx_const",
32 name: "as_conversions",
34 desc: "using a potentially dangerous silent `as` conversion",
36 module: "as_conversions",
39 name: "assertions_on_constants",
41 desc: "`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`",
43 module: "assertions_on_constants",
46 name: "assign_op_pattern",
48 desc: "assigning the result of an operation on a variable to that same variable",
55 desc: "expressions of the form `_ & mask == select` that will only ever return `true` or `false`",
60 name: "blacklisted_name",
62 desc: "usage of a blacklisted/placeholder name",
64 module: "blacklisted_name",
67 name: "block_in_if_condition_expr",
69 desc: "braces that can be eliminated in conditions, e.g., `if { true } ...`",
71 module: "block_in_if_condition",
74 name: "block_in_if_condition_stmt",
76 desc: "complex blocks in conditions, e.g., `if { let x = true; x } ...`",
78 module: "block_in_if_condition",
81 name: "bool_comparison",
83 desc: "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`",
85 module: "needless_bool",
88 name: "borrow_interior_mutable_const",
90 desc: "referencing `const` with interior mutability",
92 module: "non_copy_const",
97 desc: "a borrow of a boxed type",
104 desc: "usage of `Box<Vec<T>>`, vector elements are already on the heap",
111 desc: "using `Box<T>` where unnecessary",
116 name: "builtin_type_shadow",
118 desc: "shadowing a builtin type",
120 module: "misc_early",
123 name: "cargo_common_metadata",
125 desc: "common metadata is defined in `Cargo.toml`",
127 module: "cargo_common_metadata",
130 name: "cast_lossless",
132 desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
137 name: "cast_possible_truncation",
139 desc: "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`",
144 name: "cast_possible_wrap",
146 desc: "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`",
151 name: "cast_precision_loss",
153 desc: "casts that cause loss of precision, e.g., `x as f32` where `x: u64`",
158 name: "cast_ptr_alignment",
159 group: "correctness",
160 desc: "cast from a pointer to a more-strictly-aligned pointer",
165 name: "cast_ref_to_mut",
166 group: "correctness",
167 desc: "a cast of reference to a mutable pointer",
172 name: "cast_sign_loss",
174 desc: "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`",
179 name: "char_lit_as_u8",
181 desc: "casting a character literal to `u8` truncates",
186 name: "chars_last_cmp",
188 desc: "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char",
193 name: "chars_next_cmp",
195 desc: "using `.chars().next()` to check if a string starts with a char",
200 name: "checked_conversions",
202 desc: "`try_from` could replace manual bounds checking when casting",
204 module: "checked_conversions",
207 name: "clone_double_ref",
208 group: "correctness",
209 desc: "using `clone` on `&&T`",
214 name: "clone_on_copy",
216 desc: "using `clone` on a `Copy` type",
221 name: "clone_on_ref_ptr",
222 group: "restriction",
223 desc: "using \'clone\' on a ref-counted pointer",
229 group: "correctness",
230 desc: "comparisons to `NAN`, which will always return false, probably not intended",
237 desc: "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead.",
244 desc: "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`",
249 name: "cognitive_complexity",
251 desc: "functions that should be split up into multiple functions",
253 module: "cognitive_complexity",
256 name: "collapsible_if",
258 desc: "`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)",
260 module: "collapsible_if",
263 name: "comparison_chain",
265 desc: "`if`s that can be rewritten with `match` and `cmp`",
267 module: "comparison_chain",
270 name: "copy_iterator",
272 desc: "implementing `Iterator` on a `Copy` type",
274 module: "copy_iterator",
277 name: "crosspointer_transmute",
279 desc: "transmutes that have to or from types that are a pointer to the other",
285 group: "restriction",
286 desc: "`dbg!` macro is intended as a debugging tool",
291 name: "debug_assert_with_mut_call",
292 group: "correctness",
293 desc: "mutable arguments in `debug_assert{,_ne,_eq}!`",
295 module: "mutable_debug_assertion",
298 name: "decimal_literal_representation",
299 group: "restriction",
300 desc: "using decimal representation when hexadecimal would be better",
302 module: "literal_representation",
305 name: "declare_interior_mutable_const",
306 group: "correctness",
307 desc: "declaring `const` with interior mutability",
309 module: "non_copy_const",
312 name: "default_trait_access",
314 desc: "checks for literal calls to `Default::default()`",
316 module: "default_trait_access",
319 name: "deprecated_cfg_attr",
321 desc: "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`",
326 name: "deprecated_semver",
327 group: "correctness",
328 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
333 name: "deref_addrof",
335 desc: "use of `*&` or `*&mut` in an expression",
340 name: "derive_hash_xor_eq",
341 group: "correctness",
342 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
347 name: "diverging_sub_expression",
349 desc: "whether an expression contains a diverging sub expression",
351 module: "eval_order_dependence",
354 name: "doc_markdown",
356 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
361 name: "double_comparisons",
363 desc: "unnecessary double comparisons that can be simplified",
365 module: "double_comparison",
368 name: "double_must_use",
370 desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method",
377 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
379 module: "misc_early",
382 name: "double_parens",
384 desc: "Warn on unnecessary double parentheses",
386 module: "double_parens",
390 group: "correctness",
391 desc: "Bounds of the form `T: Drop` are useless",
393 module: "drop_bounds",
397 group: "correctness",
398 desc: "calls to `std::mem::drop` with a value that implements Copy",
400 module: "drop_forget_ref",
404 group: "correctness",
405 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
407 module: "drop_forget_ref",
410 name: "duplicate_underscore_argument",
412 desc: "function arguments having names which only differ by an underscore",
414 module: "misc_early",
417 name: "duration_subsec",
419 desc: "checks for calculation of subsecond microseconds or milliseconds",
421 module: "duration_subsec",
424 name: "else_if_without_else",
425 group: "restriction",
426 desc: "`if` expression with an `else if`, but without a final `else` branch",
428 module: "else_if_without_else",
433 desc: "enum with no variants",
435 module: "empty_enum",
438 name: "empty_line_after_outer_attr",
440 desc: "empty line after outer attribute",
447 desc: "empty `loop {}`, which should block or sleep",
452 name: "enum_clike_unportable_variant",
453 group: "correctness",
454 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
456 module: "enum_clike",
459 name: "enum_glob_use",
461 desc: "use items that import all variants of an enum",
463 module: "enum_glob_use",
466 name: "enum_variant_names",
468 desc: "enums where all variants share a prefix/postfix",
470 module: "enum_variants",
474 group: "correctness",
475 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
481 group: "correctness",
482 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
484 module: "erasing_op",
487 name: "eval_order_dependence",
489 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
491 module: "eval_order_dependence",
494 name: "excessive_precision",
496 desc: "excessive precision for float literal",
498 module: "excessive_precision",
502 group: "restriction",
503 desc: "`std::process::exit` is called, terminating the program",
508 name: "expect_fun_call",
510 desc: "using any `expect` method with a function call",
515 name: "expl_impl_clone_on_copy",
517 desc: "implementing `Clone` explicitly on `Copy` types",
522 name: "explicit_counter_loop",
524 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
529 name: "explicit_into_iter_loop",
531 desc: "for-looping over `_.into_iter()` when `_` would do",
536 name: "explicit_iter_loop",
538 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
543 name: "explicit_write",
545 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
547 module: "explicit_write",
550 name: "extra_unused_lifetimes",
552 desc: "unused lifetimes in function definitions",
557 name: "fallible_impl_from",
559 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
561 module: "fallible_impl_from",
566 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
571 name: "filter_map_next",
573 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
580 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
587 desc: "using a combination of `find` and `map` can usually be written as a single method call",
592 name: "flat_map_identity",
594 desc: "call to `flat_map` where `flatten` is sufficient",
599 name: "float_arithmetic",
600 group: "restriction",
601 desc: "any floating-point arithmetic statement",
603 module: "arithmetic",
607 group: "correctness",
608 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
613 name: "float_cmp_const",
614 group: "restriction",
615 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
620 name: "fn_to_numeric_cast",
622 desc: "casting a function pointer to a numeric type other than usize",
627 name: "fn_to_numeric_cast_with_truncation",
629 desc: "casting a function pointer to a numeric type not wide enough to store the address",
636 desc: "looping on a map using `iter` when `keys` or `values` would do",
641 name: "for_loop_over_option",
642 group: "correctness",
643 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
648 name: "for_loop_over_result",
649 group: "correctness",
650 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
656 group: "correctness",
657 desc: "calls to `std::mem::forget` with a value that implements Copy",
659 module: "drop_forget_ref",
663 group: "correctness",
664 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
666 module: "drop_forget_ref",
669 name: "get_last_with_len",
671 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
673 module: "get_last_with_len",
677 group: "restriction",
678 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
683 name: "identity_conversion",
685 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
687 module: "identity_conversion",
692 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
694 module: "identity_op",
697 name: "if_let_some_result",
699 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
706 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
708 module: "if_not_else",
711 name: "if_same_then_else",
712 group: "correctness",
713 desc: "`if` with the same `then` and `else` blocks",
718 name: "ifs_same_cond",
719 group: "correctness",
720 desc: "consecutive `if`s with the same condition",
725 name: "implicit_hasher",
727 desc: "missing generalization over different hashers",
732 name: "implicit_return",
733 group: "restriction",
734 desc: "use a return statement like `return expr` instead of an expression",
736 module: "implicit_return",
739 name: "inconsistent_digit_grouping",
741 desc: "integer literals with digits grouped inconsistently",
743 module: "literal_representation",
746 name: "indexing_slicing",
747 group: "restriction",
748 desc: "indexing/slicing usage",
750 module: "indexing_slicing",
753 name: "ineffective_bit_mask",
754 group: "correctness",
755 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
760 name: "inefficient_to_string",
762 desc: "using `to_string` on `&&T` where `T: ToString`",
767 name: "infallible_destructuring_match",
769 desc: "a `match` statement with a single infallible arm instead of a `let`",
771 module: "infallible_destructuring_match",
774 name: "infinite_iter",
775 group: "correctness",
776 desc: "infinite iteration",
778 module: "infinite_iter",
781 name: "inherent_to_string",
783 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
785 module: "inherent_to_string",
788 name: "inherent_to_string_shadow_display",
789 group: "correctness",
790 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait",
792 module: "inherent_to_string",
795 name: "inline_always",
797 desc: "use of `#[inline(always)]`",
802 name: "inline_fn_without_body",
803 group: "correctness",
804 desc: "use of `#[inline]` on trait methods without bodies",
806 module: "inline_fn_without_body",
809 name: "int_plus_one",
811 desc: "instead of using `x >= y + 1`, use `x > y`",
813 module: "int_plus_one",
816 name: "integer_arithmetic",
817 group: "restriction",
818 desc: "any integer arithmetic statement",
820 module: "arithmetic",
823 name: "integer_division",
824 group: "restriction",
825 desc: "integer division may cause loss of precision",
827 module: "integer_division",
830 name: "into_iter_on_ref",
832 desc: "using `.into_iter()` on a reference",
837 name: "invalid_atomic_ordering",
838 group: "correctness",
839 desc: "usage of invalid atomic ordering in atomic load/store calls",
841 module: "atomic_ordering",
844 name: "invalid_regex",
845 group: "correctness",
846 desc: "invalid regular expressions",
851 name: "invalid_upcast_comparisons",
853 desc: "a comparison involving an upcast which is always true or false",
858 name: "items_after_statements",
860 desc: "blocks where an item comes after a statement",
862 module: "items_after_statements",
865 name: "iter_cloned_collect",
867 desc: "using `.cloned().collect()` on slice to create a `Vec`",
872 name: "iter_next_loop",
873 group: "correctness",
874 desc: "for-looping over `_.next()` which is probably not intended",
881 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
886 name: "iter_nth_zero",
888 desc: "replace `iter.nth(0)` with `iter.next()`",
893 name: "iter_skip_next",
895 desc: "using `.skip(x).next()` on an iterator",
900 name: "iterator_step_by_zero",
901 group: "correctness",
902 desc: "using `Iterator::step_by(0)`, which will panic at runtime",
907 name: "just_underscores_and_digits",
909 desc: "unclear name",
911 module: "non_expressive_names",
914 name: "large_digit_groups",
916 desc: "grouping digits into groups that are too large",
918 module: "literal_representation",
921 name: "large_enum_variant",
923 desc: "large size difference between variants on an enum",
925 module: "large_enum_variant",
928 name: "large_stack_arrays",
930 desc: "allocating large arrays on stack may cause stack overflow",
932 module: "large_stack_arrays",
935 name: "len_without_is_empty",
937 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
944 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
949 name: "let_and_return",
951 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
956 name: "let_underscore_must_use",
957 group: "restriction",
958 desc: "non-binding let on a `#[must_use]` expression",
960 module: "let_underscore",
963 name: "let_unit_value",
965 desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
972 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`",
978 group: "correctness",
979 desc: "boolean expressions that contain terminals which can be eliminated",
984 name: "main_recursion",
986 desc: "recursion using the entrypoint",
988 module: "main_recursion",
991 name: "manual_memcpy",
993 desc: "manually copying items between slices",
998 name: "manual_mul_add",
1000 desc: "Using `a.mul_add(b, c)` for floating points has higher numerical precision than `a * b + c`",
1005 name: "manual_saturating_arithmetic",
1007 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
1012 name: "manual_swap",
1013 group: "complexity",
1014 desc: "manual swap of two variables",
1019 name: "many_single_char_names",
1021 desc: "too many single character bindings",
1023 module: "non_expressive_names",
1028 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1030 module: "map_clone",
1035 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1040 name: "map_flatten",
1042 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1047 name: "match_as_ref",
1048 group: "complexity",
1049 desc: "a `match` on an Option value instead of using `as_ref()` or `as_mut`",
1056 desc: "a `match` on a boolean expression instead of an `if..else` block",
1061 name: "match_overlapping_arm",
1063 desc: "a `match` with overlapping arms",
1068 name: "match_ref_pats",
1070 desc: "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1075 name: "match_same_arms",
1077 desc: "`match` with identical arm bodies",
1082 name: "match_wild_err_arm",
1084 desc: "a `match` with `Err(_)` arm and take drastic actions",
1089 name: "maybe_infinite_iter",
1091 desc: "possible infinite iteration",
1093 module: "infinite_iter",
1096 name: "mem_discriminant_non_enum",
1097 group: "correctness",
1098 desc: "calling `mem::descriminant` on non-enum type",
1100 module: "mem_discriminant",
1104 group: "restriction",
1105 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1107 module: "mem_forget",
1110 name: "mem_replace_option_with_none",
1112 desc: "replacing an `Option` with `None` instead of `take()`",
1114 module: "mem_replace",
1117 name: "mem_replace_with_default",
1119 desc: "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`",
1121 module: "mem_replace",
1124 name: "mem_replace_with_uninit",
1125 group: "correctness",
1126 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1128 module: "mem_replace",
1132 group: "correctness",
1133 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1138 name: "misrefactored_assign_op",
1139 group: "complexity",
1140 desc: "having a variable on both sides of an assign op",
1142 module: "assign_ops",
1145 name: "missing_const_for_fn",
1147 desc: "Lint functions definitions that could be made `const fn`",
1149 module: "missing_const_for_fn",
1152 name: "missing_docs_in_private_items",
1153 group: "restriction",
1154 desc: "detects missing documentation for public and private members",
1156 module: "missing_doc",
1159 name: "missing_errors_doc",
1161 desc: "`pub fn` returns `Result` without `# Errors` in doc comment",
1166 name: "missing_inline_in_public_items",
1167 group: "restriction",
1168 desc: "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)",
1170 module: "missing_inline",
1173 name: "missing_safety_doc",
1175 desc: "`pub unsafe fn` without `# Safety` docs",
1180 name: "mistyped_literal_suffixes",
1181 group: "correctness",
1182 desc: "mistyped literal suffix",
1184 module: "literal_representation",
1187 name: "mixed_case_hex_literals",
1189 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1191 module: "misc_early",
1194 name: "module_inception",
1196 desc: "modules that have the same name as their parent module",
1198 module: "enum_variants",
1201 name: "module_name_repetitions",
1203 desc: "type names prefixed/postfixed with their containing module\'s name",
1205 module: "enum_variants",
1208 name: "modulo_arithmetic",
1209 group: "restriction",
1210 desc: "any modulo arithmetic statement",
1212 module: "modulo_arithmetic",
1216 group: "correctness",
1217 desc: "taking a number modulo 1, which always returns 0",
1222 name: "multiple_crate_versions",
1224 desc: "multiple versions of the same crate being used",
1226 module: "multiple_crate_versions",
1229 name: "multiple_inherent_impl",
1230 group: "restriction",
1231 desc: "Multiple inherent impl that could be grouped",
1233 module: "inherent_impl",
1236 name: "must_use_candidate",
1238 desc: "function or method that could take a `#[must_use]` attribute",
1240 module: "functions",
1243 name: "must_use_unit",
1245 desc: "`#[must_use]` attribute on a unit-returning function / method",
1247 module: "functions",
1250 name: "mut_from_ref",
1251 group: "correctness",
1252 desc: "fns that create mutable refs from immutable ref args",
1259 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1264 name: "mut_range_bound",
1265 group: "complexity",
1266 desc: "for loop over a range where one of the bounds is a mutable variable",
1271 name: "mutable_key_type",
1272 group: "correctness",
1273 desc: "Check for mutable `Map`/`Set` key type",
1278 name: "mutex_atomic",
1280 desc: "using a mutex where an atomic value could be used instead",
1282 module: "mutex_atomic",
1285 name: "mutex_integer",
1287 desc: "using a mutex for an integer type",
1289 module: "mutex_atomic",
1292 name: "naive_bytecount",
1294 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1296 module: "bytecount",
1299 name: "needless_bool",
1300 group: "complexity",
1301 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1303 module: "needless_bool",
1306 name: "needless_borrow",
1308 desc: "taking a reference that is going to be automatically dereferenced",
1310 module: "needless_borrow",
1313 name: "needless_borrowed_reference",
1314 group: "complexity",
1315 desc: "taking a needless borrowed reference",
1317 module: "needless_borrowed_ref",
1320 name: "needless_collect",
1322 desc: "collecting an iterator when collect is not needed",
1327 name: "needless_continue",
1329 desc: "`continue` statements that can be replaced by a rearrangement of code",
1331 module: "needless_continue",
1334 name: "needless_doctest_main",
1336 desc: "presence of `fn main() {` in code examples",
1341 name: "needless_lifetimes",
1342 group: "complexity",
1343 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1345 module: "lifetimes",
1348 name: "needless_pass_by_value",
1350 desc: "functions taking arguments by value, but not consuming them in its body",
1352 module: "needless_pass_by_value",
1355 name: "needless_range_loop",
1357 desc: "for-looping over a range of indices where an iterator over items would do",
1362 name: "needless_return",
1364 desc: "using a return statement like `return expr;` where an expression would suffice",
1369 name: "needless_update",
1370 group: "complexity",
1371 desc: "using `Foo { ..base }` when there are no missing fields",
1373 module: "needless_update",
1376 name: "neg_cmp_op_on_partial_ord",
1377 group: "complexity",
1378 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1380 module: "neg_cmp_op_on_partial_ord",
1383 name: "neg_multiply",
1385 desc: "multiplying integers with `-1`",
1387 module: "neg_multiply",
1391 group: "correctness",
1392 desc: "any loop that will always `break` or `return`",
1397 name: "new_ret_no_self",
1399 desc: "not returning `Self` in a `new` method",
1404 name: "new_without_default",
1406 desc: "`fn new() -> Self` method without `Default` implementation",
1408 module: "new_without_default",
1412 group: "complexity",
1413 desc: "statements with no effect",
1415 module: "no_effect",
1418 name: "non_ascii_literal",
1420 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1425 name: "nonminimal_bool",
1426 group: "complexity",
1427 desc: "boolean expressions that can be written more concisely",
1432 name: "nonsensical_open_options",
1433 group: "correctness",
1434 desc: "nonsensical combination of options for opening a file",
1436 module: "open_options",
1439 name: "not_unsafe_ptr_arg_deref",
1440 group: "correctness",
1441 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1443 module: "functions",
1448 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1455 desc: "taking a reference to satisfy the type constraints on `==`",
1460 name: "option_and_then_some",
1461 group: "complexity",
1462 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1467 name: "option_expect_used",
1468 group: "restriction",
1469 desc: "using `Option.expect()`, which might be better handled",
1474 name: "option_map_or_none",
1476 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1481 name: "option_map_unit_fn",
1482 group: "complexity",
1483 desc: "using `option.map(f)`, where `f` is a function or closure that returns `()`",
1485 module: "map_unit_fn",
1488 name: "option_map_unwrap_or",
1490 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1495 name: "option_map_unwrap_or_else",
1497 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1502 name: "option_option",
1503 group: "complexity",
1504 desc: "usage of `Option<Option<T>>`",
1509 name: "option_unwrap_used",
1510 group: "restriction",
1511 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1516 name: "or_fun_call",
1518 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1523 name: "out_of_bounds_indexing",
1524 group: "correctness",
1525 desc: "out of bounds constant indexing",
1527 module: "indexing_slicing",
1530 name: "overflow_check_conditional",
1531 group: "complexity",
1532 desc: "overflow checks inspired by C which are likely to panic",
1534 module: "overflow_check_conditional",
1538 group: "restriction",
1539 desc: "usage of the `panic!` macro",
1541 module: "panic_unimplemented",
1544 name: "panic_params",
1546 desc: "missing parameters in `panic!` calls",
1548 module: "panic_unimplemented",
1551 name: "panicking_unwrap",
1552 group: "correctness",
1553 desc: "checks for calls of `unwrap[_err]()` that will always fail",
1558 name: "partialeq_ne_impl",
1559 group: "complexity",
1560 desc: "re-implementing `PartialEq::ne`",
1562 module: "partialeq_ne_impl",
1565 name: "path_buf_push_overwrite",
1567 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1569 module: "path_buf_push_overwrite",
1572 name: "possible_missing_comma",
1573 group: "correctness",
1574 desc: "possible missing comma in array",
1576 module: "formatting",
1580 group: "complexity",
1581 desc: "operations where precedence may be unclear",
1583 module: "precedence",
1586 name: "print_literal",
1588 desc: "printing a literal with a format string",
1593 name: "print_stdout",
1594 group: "restriction",
1595 desc: "printing on stdout",
1600 name: "print_with_newline",
1602 desc: "using `print!()` with a format string that ends in a single newline",
1607 name: "println_empty_string",
1609 desc: "using `println!(\"\")` with an empty string",
1616 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1621 name: "ptr_offset_with_cast",
1622 group: "complexity",
1623 desc: "unneeded pointer offset cast",
1625 module: "ptr_offset_with_cast",
1628 name: "pub_enum_variant_names",
1630 desc: "enums where all variants share a prefix/postfix",
1632 module: "enum_variants",
1635 name: "question_mark",
1637 desc: "checks for expressions that could be replaced by the question mark operator",
1639 module: "question_mark",
1642 name: "range_minus_one",
1643 group: "complexity",
1644 desc: "`x..=(y-1)` reads better as `x..y`",
1649 name: "range_plus_one",
1650 group: "complexity",
1651 desc: "`x..(y+1)` reads better as `x..=y`",
1656 name: "range_zip_with_len",
1657 group: "complexity",
1658 desc: "zipping iterator with a range when `enumerate()` would do",
1663 name: "redundant_clone",
1665 desc: "`clone()` of an owned value that is going to be dropped immediately",
1667 module: "redundant_clone",
1670 name: "redundant_closure",
1672 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1674 module: "eta_reduction",
1677 name: "redundant_closure_call",
1678 group: "complexity",
1679 desc: "throwaway closures called in the expression they are defined",
1681 module: "misc_early",
1684 name: "redundant_closure_for_method_calls",
1686 desc: "redundant closures for method calls",
1688 module: "eta_reduction",
1691 name: "redundant_field_names",
1693 desc: "checks for fields in struct literals where shorthands could be used",
1695 module: "redundant_field_names",
1698 name: "redundant_pattern",
1700 desc: "using `name @ _` in a pattern",
1702 module: "misc_early",
1705 name: "redundant_pattern_matching",
1707 desc: "use the proper utility function avoiding an `if let`",
1709 module: "redundant_pattern_matching",
1712 name: "redundant_static_lifetimes",
1714 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1716 module: "redundant_static_lifetimes",
1719 name: "ref_in_deref",
1720 group: "complexity",
1721 desc: "Use of reference in auto dereference expression.",
1723 module: "reference",
1726 name: "regex_macro",
1728 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1733 name: "replace_consts",
1735 desc: "Lint usages of standard library `const`s that could be replaced by `const fn`s",
1737 module: "replace_consts",
1740 name: "result_expect_used",
1741 group: "restriction",
1742 desc: "using `Result.expect()`, which might be better handled",
1747 name: "result_map_unit_fn",
1748 group: "complexity",
1749 desc: "using `result.map(f)`, where `f` is a function or closure that returns `()`",
1751 module: "map_unit_fn",
1754 name: "result_map_unwrap_or_else",
1756 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.map_or_else(g, f)`",
1761 name: "result_unwrap_used",
1762 group: "restriction",
1763 desc: "using `Result.unwrap()`, which might be better handled",
1768 name: "reverse_range_loop",
1769 group: "correctness",
1770 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1775 name: "same_functions_in_if_condition",
1777 desc: "consecutive `if`s with the same function call",
1782 name: "search_is_some",
1783 group: "complexity",
1784 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1789 name: "serde_api_misuse",
1790 group: "correctness",
1791 desc: "various things that will negatively affect your serde experience",
1793 module: "serde_api",
1796 name: "shadow_reuse",
1797 group: "restriction",
1798 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1803 name: "shadow_same",
1804 group: "restriction",
1805 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1810 name: "shadow_unrelated",
1812 desc: "rebinding a name without even using the original value",
1817 name: "short_circuit_statement",
1818 group: "complexity",
1819 desc: "using a short circuit boolean condition as a statement",
1824 name: "should_implement_trait",
1826 desc: "defining a method that should be implementing a std trait",
1831 name: "similar_names",
1833 desc: "similarly named items and bindings",
1835 module: "non_expressive_names",
1838 name: "single_char_pattern",
1840 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1845 name: "single_match",
1847 desc: "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1852 name: "single_match_else",
1854 desc: "a `match` statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1859 name: "slow_vector_initialization",
1861 desc: "slow vector initialization",
1863 module: "slow_vector_initialization",
1867 group: "restriction",
1868 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1873 name: "string_add_assign",
1875 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1880 name: "string_extend_chars",
1882 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1887 name: "string_lit_as_bytes",
1889 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1894 name: "suspicious_arithmetic_impl",
1895 group: "correctness",
1896 desc: "suspicious use of operators in impl of arithmetic trait",
1898 module: "suspicious_trait_impl",
1901 name: "suspicious_assignment_formatting",
1903 desc: "suspicious formatting of `*=`, `-=` or `!=`",
1905 module: "formatting",
1908 name: "suspicious_else_formatting",
1910 desc: "suspicious formatting of `else`",
1912 module: "formatting",
1915 name: "suspicious_map",
1916 group: "complexity",
1917 desc: "suspicious usage of map",
1922 name: "suspicious_op_assign_impl",
1923 group: "correctness",
1924 desc: "suspicious use of operators in impl of OpAssign trait",
1926 module: "suspicious_trait_impl",
1929 name: "suspicious_unary_op_formatting",
1931 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
1933 module: "formatting",
1936 name: "tabs_in_doc_comments",
1938 desc: "using tabs in doc comments is not recommended",
1940 module: "tabs_in_doc_comments",
1943 name: "temporary_assignment",
1944 group: "complexity",
1945 desc: "assignments to temporaries",
1947 module: "temporary_assignment",
1950 name: "temporary_cstring_as_ptr",
1951 group: "correctness",
1952 desc: "getting the inner pointer of a temporary `CString`",
1957 name: "to_digit_is_some",
1959 desc: "`char.is_digit()` is clearer",
1961 module: "to_digit_is_some",
1965 group: "restriction",
1966 desc: "`todo!` should not be present in production code",
1968 module: "panic_unimplemented",
1971 name: "too_many_arguments",
1972 group: "complexity",
1973 desc: "functions with too many arguments",
1975 module: "functions",
1978 name: "too_many_lines",
1980 desc: "functions with too many lines",
1982 module: "functions",
1985 name: "toplevel_ref_arg",
1987 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
1992 name: "transmute_bytes_to_str",
1993 group: "complexity",
1994 desc: "transmutes from a `&[u8]` to a `&str`",
1996 module: "transmute",
1999 name: "transmute_float_to_int",
2001 desc: "transmutes from a float to an integer",
2003 module: "transmute",
2006 name: "transmute_int_to_bool",
2007 group: "complexity",
2008 desc: "transmutes from an integer to a `bool`",
2010 module: "transmute",
2013 name: "transmute_int_to_char",
2014 group: "complexity",
2015 desc: "transmutes from an integer to a `char`",
2017 module: "transmute",
2020 name: "transmute_int_to_float",
2021 group: "complexity",
2022 desc: "transmutes from an integer to a float",
2024 module: "transmute",
2027 name: "transmute_ptr_to_ptr",
2028 group: "complexity",
2029 desc: "transmutes from a pointer to a pointer / a reference to a reference",
2031 module: "transmute",
2034 name: "transmute_ptr_to_ref",
2035 group: "complexity",
2036 desc: "transmutes from a pointer to a reference type",
2038 module: "transmute",
2041 name: "transmuting_null",
2042 group: "correctness",
2043 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
2045 module: "transmuting_null",
2048 name: "trivial_regex",
2050 desc: "trivial regular expressions",
2055 name: "trivially_copy_pass_by_ref",
2057 desc: "functions taking small copyable arguments by reference",
2059 module: "trivially_copy_pass_by_ref",
2064 desc: "return errors explicitly rather than hiding them behind a `?`",
2069 name: "type_complexity",
2070 group: "complexity",
2071 desc: "usage of very complex types that might be better factored into `type` definitions",
2076 name: "type_repetition_in_bounds",
2078 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2080 module: "trait_bounds",
2083 name: "unicode_not_nfc",
2085 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2090 name: "unimplemented",
2091 group: "restriction",
2092 desc: "`unimplemented!` should not be present in production code",
2094 module: "panic_unimplemented",
2097 name: "uninit_assumed_init",
2098 group: "correctness",
2099 desc: "`MaybeUninit::uninit().assume_init()`",
2105 group: "complexity",
2106 desc: "passing unit to a function",
2112 group: "correctness",
2113 desc: "comparing unit values",
2118 name: "unknown_clippy_lints",
2120 desc: "unknown_lints for scoped Clippy lints",
2125 name: "unnecessary_cast",
2126 group: "complexity",
2127 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2132 name: "unnecessary_filter_map",
2133 group: "complexity",
2134 desc: "using `filter_map` when a more succinct alternative exists",
2139 name: "unnecessary_fold",
2141 desc: "using `fold` when a more succinct alternative exists",
2146 name: "unnecessary_mut_passed",
2148 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2150 module: "mut_reference",
2153 name: "unnecessary_operation",
2154 group: "complexity",
2155 desc: "outer expressions with no effect",
2157 module: "no_effect",
2160 name: "unnecessary_unwrap",
2161 group: "complexity",
2162 desc: "checks for calls of `unwrap[_err]()` that cannot fail",
2167 name: "unneeded_field_pattern",
2169 desc: "struct fields bound to a wildcard instead of using `..`",
2171 module: "misc_early",
2174 name: "unneeded_wildcard_pattern",
2175 group: "complexity",
2176 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2178 module: "misc_early",
2181 name: "unreachable",
2182 group: "restriction",
2183 desc: "`unreachable!` should not be present in production code",
2185 module: "panic_unimplemented",
2188 name: "unreadable_literal",
2190 desc: "long integer literal without underscores",
2192 module: "literal_representation",
2195 name: "unsafe_removed_from_name",
2197 desc: "`unsafe` removed from API names on import",
2199 module: "unsafe_removed_from_name",
2202 name: "unseparated_literal_suffix",
2204 desc: "literals whose suffix is not separated by an underscore",
2206 module: "misc_early",
2209 name: "unsound_collection_transmute",
2210 group: "correctness",
2211 desc: "transmute between collections of layout-incompatible types",
2213 module: "transmute",
2216 name: "unused_io_amount",
2217 group: "correctness",
2218 desc: "unused written/read amount",
2220 module: "unused_io_amount",
2223 name: "unused_self",
2225 desc: "methods that contain a `self` argument but don\'t use it",
2227 module: "unused_self",
2230 name: "unused_unit",
2232 desc: "needless unit expression",
2238 group: "restriction",
2239 desc: "use of `Debug`-based formatting",
2246 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2251 name: "used_underscore_binding",
2253 desc: "using a binding which is prefixed with an underscore",
2258 name: "useless_asref",
2259 group: "complexity",
2260 desc: "using `as_ref` where the types before and after the call are the same",
2265 name: "useless_attribute",
2266 group: "correctness",
2267 desc: "use of lint attributes on `extern crate` items",
2272 name: "useless_format",
2273 group: "complexity",
2274 desc: "useless use of `format!`",
2279 name: "useless_let_if_seq",
2281 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2283 module: "let_if_seq",
2286 name: "useless_transmute",
2287 group: "complexity",
2288 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2290 module: "transmute",
2293 name: "useless_vec",
2295 desc: "useless `vec!`",
2301 group: "complexity",
2302 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2307 name: "verbose_bit_mask",
2309 desc: "expressions where a bit mask is less readable than the corresponding method call",
2314 name: "while_immutable_condition",
2315 group: "correctness",
2316 desc: "variables used within while expression are not mutated in the body",
2321 name: "while_let_loop",
2322 group: "complexity",
2323 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2328 name: "while_let_on_iterator",
2330 desc: "using a while-let loop instead of a for loop on an iterator",
2335 name: "wildcard_dependencies",
2337 desc: "wildcard dependencies being used",
2339 module: "wildcard_dependencies",
2342 name: "wildcard_enum_match_arm",
2343 group: "restriction",
2344 desc: "a wildcard enum match arm using `_`",
2349 name: "write_literal",
2351 desc: "writing a literal with a format string",
2356 name: "write_with_newline",
2358 desc: "using `write!()` with a format string that ends in a single newline",
2363 name: "writeln_empty_string",
2365 desc: "using `writeln!(buf, \"\")` with an empty string",
2370 name: "wrong_pub_self_convention",
2371 group: "restriction",
2372 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2377 name: "wrong_self_convention",
2379 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2384 name: "wrong_transmute",
2385 group: "correctness",
2386 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2388 module: "transmute",
2391 name: "zero_divided_by_zero",
2392 group: "complexity",
2393 desc: "usage of `0.0 / 0.0` to obtain NaN instead of `std::f32::NAN` or `std::f64::NAN`",
2395 module: "zero_div_zero",
2398 name: "zero_prefixed_literal",
2399 group: "complexity",
2400 desc: "integer literals starting with `0`",
2402 module: "misc_early",
2407 desc: "using `0 as *{const, mut} T`",
2412 name: "zero_width_space",
2413 group: "correctness",
2414 desc: "using a zero-width space in a string literal, which is confusing",
2420 group: "correctness",
2421 desc: "Check for offset calculations on raw pointers to zero-sized types",
2426 // end lint list, do not remove this comment, it’s used in `update_lints`