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; 334] = [
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: "assertions_on_constants",
34 desc: "`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`",
36 module: "assertions_on_constants",
39 name: "assign_op_pattern",
41 desc: "assigning the result of an operation on a variable to that same variable",
48 desc: "expressions of the form `_ & mask == select` that will only ever return `true` or `false`",
53 name: "blacklisted_name",
55 desc: "usage of a blacklisted/placeholder name",
57 module: "blacklisted_name",
60 name: "block_in_if_condition_expr",
62 desc: "braces that can be eliminated in conditions, e.g., `if { true } ...`",
64 module: "block_in_if_condition",
67 name: "block_in_if_condition_stmt",
69 desc: "complex blocks in conditions, e.g., `if { let x = true; x } ...`",
71 module: "block_in_if_condition",
74 name: "bool_comparison",
76 desc: "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`",
78 module: "needless_bool",
81 name: "borrow_interior_mutable_const",
83 desc: "referencing const with interior mutability",
85 module: "non_copy_const",
90 desc: "a borrow of a boxed type",
97 desc: "usage of `Box<Vec<T>>`, vector elements are already on the heap",
104 desc: "using `Box<T>` where unnecessary",
109 name: "builtin_type_shadow",
111 desc: "shadowing a builtin type",
113 module: "misc_early",
116 name: "cargo_common_metadata",
118 desc: "common metadata is defined in `Cargo.toml`",
120 module: "cargo_common_metadata",
123 name: "cast_lossless",
125 desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
130 name: "cast_possible_truncation",
132 desc: "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`",
137 name: "cast_possible_wrap",
139 desc: "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`",
144 name: "cast_precision_loss",
146 desc: "casts that cause loss of precision, e.g., `x as f32` where `x: u64`",
151 name: "cast_ptr_alignment",
152 group: "correctness",
153 desc: "cast from a pointer to a more-strictly-aligned pointer",
158 name: "cast_ref_to_mut",
159 group: "correctness",
160 desc: "a cast of reference to a mutable pointer",
165 name: "cast_sign_loss",
167 desc: "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`",
172 name: "char_lit_as_u8",
174 desc: "casting a character literal to u8 truncates",
179 name: "chars_last_cmp",
181 desc: "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char",
186 name: "chars_next_cmp",
188 desc: "using `.chars().next()` to check if a string starts with a char",
193 name: "checked_conversions",
195 desc: "`try_from` could replace manual bounds checking when casting",
197 module: "checked_conversions",
200 name: "clone_double_ref",
201 group: "correctness",
202 desc: "using `clone` on `&&T`",
207 name: "clone_on_copy",
209 desc: "using `clone` on a `Copy` type",
214 name: "clone_on_ref_ptr",
215 group: "restriction",
216 desc: "using \'clone\' on a ref-counted pointer",
222 group: "correctness",
223 desc: "comparisons to NAN, which will always return false, probably not intended",
230 desc: "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead.",
237 desc: "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`",
242 name: "cognitive_complexity",
244 desc: "functions that should be split up into multiple functions",
246 module: "cognitive_complexity",
249 name: "collapsible_if",
251 desc: "`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)",
253 module: "collapsible_if",
256 name: "comparison_chain",
258 desc: "`if`s that can be rewritten with `match` and `cmp`",
260 module: "comparison_chain",
263 name: "copy_iterator",
265 desc: "implementing `Iterator` on a `Copy` type",
267 module: "copy_iterator",
270 name: "crosspointer_transmute",
272 desc: "transmutes that have to or from types that are a pointer to the other",
278 group: "restriction",
279 desc: "`dbg!` macro is intended as a debugging tool",
284 name: "debug_assert_with_mut_call",
285 group: "correctness",
286 desc: "mutable arguments in `debug_assert{,_ne,_eq}!`",
288 module: "mutable_debug_assertion",
291 name: "decimal_literal_representation",
292 group: "restriction",
293 desc: "using decimal representation when hexadecimal would be better",
295 module: "literal_representation",
298 name: "declare_interior_mutable_const",
299 group: "correctness",
300 desc: "declaring const with interior mutability",
302 module: "non_copy_const",
305 name: "default_trait_access",
307 desc: "checks for literal calls to Default::default()",
309 module: "default_trait_access",
312 name: "deprecated_cfg_attr",
314 desc: "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`",
319 name: "deprecated_semver",
320 group: "correctness",
321 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
326 name: "deref_addrof",
328 desc: "use of `*&` or `*&mut` in an expression",
333 name: "derive_hash_xor_eq",
334 group: "correctness",
335 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
340 name: "diverging_sub_expression",
342 desc: "whether an expression contains a diverging sub expression",
344 module: "eval_order_dependence",
347 name: "doc_markdown",
349 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
354 name: "double_comparisons",
356 desc: "unnecessary double comparisons that can be simplified",
358 module: "double_comparison",
361 name: "double_must_use",
363 desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method",
370 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
372 module: "misc_early",
375 name: "double_parens",
377 desc: "Warn on unnecessary double parentheses",
379 module: "double_parens",
383 group: "correctness",
384 desc: "Bounds of the form `T: Drop` are useless",
386 module: "drop_bounds",
390 group: "correctness",
391 desc: "calls to `std::mem::drop` with a value that implements Copy",
393 module: "drop_forget_ref",
397 group: "correctness",
398 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
400 module: "drop_forget_ref",
403 name: "duplicate_underscore_argument",
405 desc: "function arguments having names which only differ by an underscore",
407 module: "misc_early",
410 name: "duration_subsec",
412 desc: "checks for calculation of subsecond microseconds or milliseconds",
414 module: "duration_subsec",
417 name: "else_if_without_else",
418 group: "restriction",
419 desc: "if expression with an `else if`, but without a final `else` branch",
421 module: "else_if_without_else",
426 desc: "enum with no variants",
428 module: "empty_enum",
431 name: "empty_line_after_outer_attr",
433 desc: "empty line after outer attribute",
440 desc: "empty `loop {}`, which should block or sleep",
445 name: "enum_clike_unportable_variant",
446 group: "correctness",
447 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
449 module: "enum_clike",
452 name: "enum_glob_use",
454 desc: "use items that import all variants of an enum",
456 module: "enum_glob_use",
459 name: "enum_variant_names",
461 desc: "enums where all variants share a prefix/postfix",
463 module: "enum_variants",
467 group: "correctness",
468 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
474 group: "correctness",
475 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
477 module: "erasing_op",
480 name: "eval_order_dependence",
482 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
484 module: "eval_order_dependence",
487 name: "excessive_precision",
489 desc: "excessive precision for float literal",
491 module: "excessive_precision",
495 group: "restriction",
496 desc: "`std::process::exit` is called, terminating the program",
501 name: "expect_fun_call",
503 desc: "using any `expect` method with a function call",
508 name: "expl_impl_clone_on_copy",
510 desc: "implementing `Clone` explicitly on `Copy` types",
515 name: "explicit_counter_loop",
517 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
522 name: "explicit_into_iter_loop",
524 desc: "for-looping over `_.into_iter()` when `_` would do",
529 name: "explicit_iter_loop",
531 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
536 name: "explicit_write",
538 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
540 module: "explicit_write",
543 name: "extra_unused_lifetimes",
545 desc: "unused lifetimes in function definitions",
550 name: "fallible_impl_from",
552 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
554 module: "fallible_impl_from",
559 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
564 name: "filter_map_next",
566 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
573 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
580 desc: "using a combination of `find` and `map` can usually be written as a single method call",
585 name: "flat_map_identity",
587 desc: "call to `flat_map` where `flatten` is sufficient",
592 name: "float_arithmetic",
593 group: "restriction",
594 desc: "any floating-point arithmetic statement",
596 module: "arithmetic",
600 group: "correctness",
601 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
606 name: "float_cmp_const",
607 group: "restriction",
608 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
613 name: "fn_to_numeric_cast",
615 desc: "casting a function pointer to a numeric type other than usize",
620 name: "fn_to_numeric_cast_with_truncation",
622 desc: "casting a function pointer to a numeric type not wide enough to store the address",
629 desc: "looping on a map using `iter` when `keys` or `values` would do",
634 name: "for_loop_over_option",
635 group: "correctness",
636 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
641 name: "for_loop_over_result",
642 group: "correctness",
643 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
649 group: "correctness",
650 desc: "calls to `std::mem::forget` with a value that implements Copy",
652 module: "drop_forget_ref",
656 group: "correctness",
657 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
659 module: "drop_forget_ref",
662 name: "get_last_with_len",
664 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
666 module: "get_last_with_len",
670 group: "restriction",
671 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
676 name: "identity_conversion",
678 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
680 module: "identity_conversion",
685 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
687 module: "identity_op",
690 name: "if_let_some_result",
692 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
699 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
701 module: "if_not_else",
704 name: "if_same_then_else",
705 group: "correctness",
706 desc: "if with the same *then* and *else* blocks",
711 name: "ifs_same_cond",
712 group: "correctness",
713 desc: "consecutive `ifs` with the same condition",
718 name: "ifs_same_cond_fn",
720 desc: "consecutive `ifs` with the same function call",
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_regex",
838 group: "correctness",
839 desc: "invalid regular expressions",
844 name: "invalid_upcast_comparisons",
846 desc: "a comparison involving an upcast which is always true or false",
851 name: "items_after_statements",
853 desc: "blocks where an item comes after a statement",
855 module: "items_after_statements",
858 name: "iter_cloned_collect",
860 desc: "using `.cloned().collect()` on slice to create a `Vec`",
865 name: "iter_next_loop",
866 group: "correctness",
867 desc: "for-looping over `_.next()` which is probably not intended",
874 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
879 name: "iter_skip_next",
881 desc: "using `.skip(x).next()` on an iterator",
886 name: "iterator_step_by_zero",
887 group: "correctness",
888 desc: "using `Iterator::step_by(0)`, which produces an infinite iterator",
893 name: "just_underscores_and_digits",
895 desc: "unclear name",
897 module: "non_expressive_names",
900 name: "large_digit_groups",
902 desc: "grouping digits into groups that are too large",
904 module: "literal_representation",
907 name: "large_enum_variant",
909 desc: "large size difference between variants on an enum",
911 module: "large_enum_variant",
914 name: "len_without_is_empty",
916 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
923 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
928 name: "let_and_return",
930 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
935 name: "let_unit_value",
937 desc: "creating a let binding to a value of unit type, which usually can\'t be used afterwards",
944 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a VecDeque",
950 group: "correctness",
951 desc: "boolean expressions that contain terminals which can be eliminated",
956 name: "main_recursion",
958 desc: "recursion using the entrypoint",
960 module: "main_recursion",
963 name: "manual_memcpy",
965 desc: "manually copying items between slices",
970 name: "manual_mul_add",
972 desc: "Using `a.mul_add(b, c)` for floating points has higher numerical precision than `a * b + c`",
977 name: "manual_saturating_arithmetic",
979 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
986 desc: "manual swap of two variables",
991 name: "many_single_char_names",
993 desc: "too many single character bindings",
995 module: "non_expressive_names",
1000 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1002 module: "map_clone",
1007 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1012 name: "map_flatten",
1014 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1019 name: "match_as_ref",
1020 group: "complexity",
1021 desc: "a match on an Option value instead of using `as_ref()` or `as_mut`",
1028 desc: "a match on a boolean expression instead of an `if..else` block",
1033 name: "match_overlapping_arm",
1035 desc: "a match with overlapping arms",
1040 name: "match_ref_pats",
1042 desc: "a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1047 name: "match_same_arms",
1049 desc: "`match` with identical arm bodies",
1054 name: "match_wild_err_arm",
1056 desc: "a match with `Err(_)` arm and take drastic actions",
1061 name: "maybe_infinite_iter",
1063 desc: "possible infinite iteration",
1065 module: "infinite_iter",
1068 name: "mem_discriminant_non_enum",
1069 group: "correctness",
1070 desc: "calling mem::descriminant on non-enum type",
1072 module: "mem_discriminant",
1076 group: "restriction",
1077 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1079 module: "mem_forget",
1082 name: "mem_replace_option_with_none",
1084 desc: "replacing an `Option` with `None` instead of `take()`",
1086 module: "mem_replace",
1089 name: "mem_replace_with_uninit",
1090 group: "correctness",
1091 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1093 module: "mem_replace",
1097 group: "correctness",
1098 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1103 name: "misrefactored_assign_op",
1104 group: "complexity",
1105 desc: "having a variable on both sides of an assign op",
1107 module: "assign_ops",
1110 name: "missing_const_for_fn",
1112 desc: "Lint functions definitions that could be made `const fn`",
1114 module: "missing_const_for_fn",
1117 name: "missing_docs_in_private_items",
1118 group: "restriction",
1119 desc: "detects missing documentation for public and private members",
1121 module: "missing_doc",
1124 name: "missing_inline_in_public_items",
1125 group: "restriction",
1126 desc: "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)",
1128 module: "missing_inline",
1131 name: "missing_safety_doc",
1133 desc: "`pub unsafe fn` without `# Safety` docs",
1138 name: "mistyped_literal_suffixes",
1139 group: "correctness",
1140 desc: "mistyped literal suffix",
1142 module: "literal_representation",
1145 name: "mixed_case_hex_literals",
1147 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1149 module: "misc_early",
1152 name: "module_inception",
1154 desc: "modules that have the same name as their parent module",
1156 module: "enum_variants",
1159 name: "module_name_repetitions",
1161 desc: "type names prefixed/postfixed with their containing module\'s name",
1163 module: "enum_variants",
1167 group: "correctness",
1168 desc: "taking a number modulo 1, which always returns 0",
1173 name: "multiple_crate_versions",
1175 desc: "multiple versions of the same crate being used",
1177 module: "multiple_crate_versions",
1180 name: "multiple_inherent_impl",
1181 group: "restriction",
1182 desc: "Multiple inherent impl that could be grouped",
1184 module: "inherent_impl",
1187 name: "must_use_candidate",
1189 desc: "function or method that could take a `#[must_use]` attribute",
1191 module: "functions",
1194 name: "must_use_unit",
1196 desc: "`#[must_use]` attribute on a unit-returning function / method",
1198 module: "functions",
1201 name: "mut_from_ref",
1202 group: "correctness",
1203 desc: "fns that create mutable refs from immutable ref args",
1210 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1215 name: "mut_range_bound",
1216 group: "complexity",
1217 desc: "for loop over a range where one of the bounds is a mutable variable",
1222 name: "mutex_atomic",
1224 desc: "using a mutex where an atomic value could be used instead",
1226 module: "mutex_atomic",
1229 name: "mutex_integer",
1231 desc: "using a mutex for an integer type",
1233 module: "mutex_atomic",
1236 name: "naive_bytecount",
1238 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1240 module: "bytecount",
1243 name: "needless_bool",
1244 group: "complexity",
1245 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1247 module: "needless_bool",
1250 name: "needless_borrow",
1252 desc: "taking a reference that is going to be automatically dereferenced",
1254 module: "needless_borrow",
1257 name: "needless_borrowed_reference",
1258 group: "complexity",
1259 desc: "taking a needless borrowed reference",
1261 module: "needless_borrowed_ref",
1264 name: "needless_collect",
1266 desc: "collecting an iterator when collect is not needed",
1271 name: "needless_continue",
1273 desc: "`continue` statements that can be replaced by a rearrangement of code",
1275 module: "needless_continue",
1278 name: "needless_doctest_main",
1280 desc: "presence of `fn main() {` in code examples",
1285 name: "needless_lifetimes",
1286 group: "complexity",
1287 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1289 module: "lifetimes",
1292 name: "needless_pass_by_value",
1294 desc: "functions taking arguments by value, but not consuming them in its body",
1296 module: "needless_pass_by_value",
1299 name: "needless_range_loop",
1301 desc: "for-looping over a range of indices where an iterator over items would do",
1306 name: "needless_return",
1308 desc: "using a return statement like `return expr;` where an expression would suffice",
1313 name: "needless_update",
1314 group: "complexity",
1315 desc: "using `Foo { ..base }` when there are no missing fields",
1317 module: "needless_update",
1320 name: "neg_cmp_op_on_partial_ord",
1321 group: "complexity",
1322 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1324 module: "neg_cmp_op_on_partial_ord",
1327 name: "neg_multiply",
1329 desc: "multiplying integers with -1",
1331 module: "neg_multiply",
1335 group: "correctness",
1336 desc: "any loop that will always `break` or `return`",
1341 name: "new_ret_no_self",
1343 desc: "not returning `Self` in a `new` method",
1348 name: "new_without_default",
1350 desc: "`fn new() -> Self` method without `Default` implementation",
1352 module: "new_without_default",
1356 group: "complexity",
1357 desc: "statements with no effect",
1359 module: "no_effect",
1362 name: "non_ascii_literal",
1364 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1369 name: "nonminimal_bool",
1370 group: "complexity",
1371 desc: "boolean expressions that can be written more concisely",
1376 name: "nonsensical_open_options",
1377 group: "correctness",
1378 desc: "nonsensical combination of options for opening a file",
1380 module: "open_options",
1383 name: "not_unsafe_ptr_arg_deref",
1384 group: "correctness",
1385 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1387 module: "functions",
1392 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1399 desc: "taking a reference to satisfy the type constraints on `==`",
1404 name: "option_and_then_some",
1405 group: "complexity",
1406 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1411 name: "option_expect_used",
1412 group: "restriction",
1413 desc: "using `Option.expect()`, which might be better handled",
1418 name: "option_map_or_none",
1420 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1425 name: "option_map_unit_fn",
1426 group: "complexity",
1427 desc: "using `option.map(f)`, where f is a function or closure that returns ()",
1429 module: "map_unit_fn",
1432 name: "option_map_unwrap_or",
1434 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1439 name: "option_map_unwrap_or_else",
1441 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1446 name: "option_option",
1447 group: "complexity",
1448 desc: "usage of `Option<Option<T>>`",
1453 name: "option_unwrap_used",
1454 group: "restriction",
1455 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1460 name: "or_fun_call",
1462 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1467 name: "out_of_bounds_indexing",
1468 group: "correctness",
1469 desc: "out of bounds constant indexing",
1471 module: "indexing_slicing",
1474 name: "overflow_check_conditional",
1475 group: "complexity",
1476 desc: "overflow checks inspired by C which are likely to panic",
1478 module: "overflow_check_conditional",
1482 group: "restriction",
1483 desc: "usage of the `panic!` macro",
1485 module: "panic_unimplemented",
1488 name: "panic_params",
1490 desc: "missing parameters in `panic!` calls",
1492 module: "panic_unimplemented",
1495 name: "panicking_unwrap",
1496 group: "correctness",
1497 desc: "checks for calls of unwrap[_err]() that will always fail",
1502 name: "partialeq_ne_impl",
1503 group: "complexity",
1504 desc: "re-implementing `PartialEq::ne`",
1506 module: "partialeq_ne_impl",
1509 name: "path_buf_push_overwrite",
1511 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1513 module: "path_buf_push_overwrite",
1516 name: "possible_missing_comma",
1517 group: "correctness",
1518 desc: "possible missing comma in array",
1520 module: "formatting",
1524 group: "complexity",
1525 desc: "operations where precedence may be unclear",
1527 module: "precedence",
1530 name: "print_literal",
1532 desc: "printing a literal with a format string",
1537 name: "print_stdout",
1538 group: "restriction",
1539 desc: "printing on stdout",
1544 name: "print_with_newline",
1546 desc: "using `print!()` with a format string that ends in a single newline",
1551 name: "println_empty_string",
1553 desc: "using `println!(\"\")` with an empty string",
1560 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1565 name: "ptr_offset_with_cast",
1566 group: "complexity",
1567 desc: "unneeded pointer offset cast",
1569 module: "ptr_offset_with_cast",
1572 name: "pub_enum_variant_names",
1574 desc: "enums where all variants share a prefix/postfix",
1576 module: "enum_variants",
1579 name: "question_mark",
1581 desc: "checks for expressions that could be replaced by the question mark operator",
1583 module: "question_mark",
1586 name: "range_minus_one",
1587 group: "complexity",
1588 desc: "`x..=(y-1)` reads better as `x..y`",
1593 name: "range_plus_one",
1594 group: "complexity",
1595 desc: "`x..(y+1)` reads better as `x..=y`",
1600 name: "range_zip_with_len",
1601 group: "complexity",
1602 desc: "zipping iterator with a range when `enumerate()` would do",
1607 name: "redundant_clone",
1609 desc: "`clone()` of an owned value that is going to be dropped immediately",
1611 module: "redundant_clone",
1614 name: "redundant_closure",
1616 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1618 module: "eta_reduction",
1621 name: "redundant_closure_call",
1622 group: "complexity",
1623 desc: "throwaway closures called in the expression they are defined",
1625 module: "misc_early",
1628 name: "redundant_closure_for_method_calls",
1630 desc: "redundant closures for method calls",
1632 module: "eta_reduction",
1635 name: "redundant_field_names",
1637 desc: "checks for fields in struct literals where shorthands could be used",
1639 module: "redundant_field_names",
1642 name: "redundant_pattern",
1644 desc: "using `name @ _` in a pattern",
1646 module: "misc_early",
1649 name: "redundant_pattern_matching",
1651 desc: "use the proper utility function avoiding an `if let`",
1653 module: "redundant_pattern_matching",
1656 name: "redundant_static_lifetimes",
1658 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1660 module: "redundant_static_lifetimes",
1663 name: "ref_in_deref",
1664 group: "complexity",
1665 desc: "Use of reference in auto dereference expression.",
1667 module: "reference",
1670 name: "regex_macro",
1672 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1677 name: "replace_consts",
1679 desc: "Lint usages of standard library `const`s that could be replaced by `const fn`s",
1681 module: "replace_consts",
1684 name: "result_expect_used",
1685 group: "restriction",
1686 desc: "using `Result.expect()`, which might be better handled",
1691 name: "result_map_unit_fn",
1692 group: "complexity",
1693 desc: "using `result.map(f)`, where f is a function or closure that returns ()",
1695 module: "map_unit_fn",
1698 name: "result_map_unwrap_or_else",
1700 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.ok().map_or_else(g, f)`",
1705 name: "result_unwrap_used",
1706 group: "restriction",
1707 desc: "using `Result.unwrap()`, which might be better handled",
1712 name: "reverse_range_loop",
1713 group: "correctness",
1714 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1719 name: "search_is_some",
1720 group: "complexity",
1721 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1726 name: "serde_api_misuse",
1727 group: "correctness",
1728 desc: "various things that will negatively affect your serde experience",
1730 module: "serde_api",
1733 name: "shadow_reuse",
1734 group: "restriction",
1735 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1740 name: "shadow_same",
1741 group: "restriction",
1742 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1747 name: "shadow_unrelated",
1749 desc: "rebinding a name without even using the original value",
1754 name: "short_circuit_statement",
1755 group: "complexity",
1756 desc: "using a short circuit boolean condition as a statement",
1761 name: "should_implement_trait",
1763 desc: "defining a method that should be implementing a std trait",
1768 name: "similar_names",
1770 desc: "similarly named items and bindings",
1772 module: "non_expressive_names",
1775 name: "single_char_pattern",
1777 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1782 name: "single_match",
1784 desc: "a match statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1789 name: "single_match_else",
1791 desc: "a match statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1796 name: "slow_vector_initialization",
1798 desc: "slow vector initialization",
1800 module: "slow_vector_initialization",
1804 group: "restriction",
1805 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1810 name: "string_add_assign",
1812 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1817 name: "string_extend_chars",
1819 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1824 name: "string_lit_as_bytes",
1826 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1831 name: "suspicious_arithmetic_impl",
1832 group: "correctness",
1833 desc: "suspicious use of operators in impl of arithmetic trait",
1835 module: "suspicious_trait_impl",
1838 name: "suspicious_assignment_formatting",
1840 desc: "suspicious formatting of `*=`, `-=` or `!=`",
1842 module: "formatting",
1845 name: "suspicious_else_formatting",
1847 desc: "suspicious formatting of `else`",
1849 module: "formatting",
1852 name: "suspicious_map",
1853 group: "complexity",
1854 desc: "suspicious usage of map",
1859 name: "suspicious_op_assign_impl",
1860 group: "correctness",
1861 desc: "suspicious use of operators in impl of OpAssign trait",
1863 module: "suspicious_trait_impl",
1866 name: "suspicious_unary_op_formatting",
1868 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
1870 module: "formatting",
1873 name: "temporary_assignment",
1874 group: "complexity",
1875 desc: "assignments to temporaries",
1877 module: "temporary_assignment",
1880 name: "temporary_cstring_as_ptr",
1881 group: "correctness",
1882 desc: "getting the inner pointer of a temporary `CString`",
1887 name: "to_digit_is_some",
1889 desc: "`char.is_digit()` is clearer",
1891 module: "to_digit_is_some",
1895 group: "restriction",
1896 desc: "`todo!` should not be present in production code",
1898 module: "panic_unimplemented",
1901 name: "too_many_arguments",
1902 group: "complexity",
1903 desc: "functions with too many arguments",
1905 module: "functions",
1908 name: "too_many_lines",
1910 desc: "functions with too many lines",
1912 module: "functions",
1915 name: "toplevel_ref_arg",
1917 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
1922 name: "transmute_bytes_to_str",
1923 group: "complexity",
1924 desc: "transmutes from a `&[u8]` to a `&str`",
1926 module: "transmute",
1929 name: "transmute_int_to_bool",
1930 group: "complexity",
1931 desc: "transmutes from an integer to a `bool`",
1933 module: "transmute",
1936 name: "transmute_int_to_char",
1937 group: "complexity",
1938 desc: "transmutes from an integer to a `char`",
1940 module: "transmute",
1943 name: "transmute_int_to_float",
1944 group: "complexity",
1945 desc: "transmutes from an integer to a float",
1947 module: "transmute",
1950 name: "transmute_ptr_to_ptr",
1951 group: "complexity",
1952 desc: "transmutes from a pointer to a pointer / a reference to a reference",
1954 module: "transmute",
1957 name: "transmute_ptr_to_ref",
1958 group: "complexity",
1959 desc: "transmutes from a pointer to a reference type",
1961 module: "transmute",
1964 name: "transmuting_null",
1965 group: "correctness",
1966 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
1968 module: "transmuting_null",
1971 name: "trivial_regex",
1973 desc: "trivial regular expressions",
1978 name: "trivially_copy_pass_by_ref",
1980 desc: "functions taking small copyable arguments by reference",
1982 module: "trivially_copy_pass_by_ref",
1987 desc: "return errors explicitly rather than hiding them behind a `?`",
1992 name: "type_complexity",
1993 group: "complexity",
1994 desc: "usage of very complex types that might be better factored into `type` definitions",
1999 name: "type_repetition_in_bounds",
2001 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2003 module: "trait_bounds",
2006 name: "unicode_not_nfc",
2008 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2013 name: "unimplemented",
2014 group: "restriction",
2015 desc: "`unimplemented!` should not be present in production code",
2017 module: "panic_unimplemented",
2020 name: "uninit_assumed_init",
2021 group: "correctness",
2022 desc: "`MaybeUninit::uninit().assume_init()`",
2028 group: "complexity",
2029 desc: "passing unit to a function",
2035 group: "correctness",
2036 desc: "comparing unit values",
2041 name: "unknown_clippy_lints",
2043 desc: "unknown_lints for scoped Clippy lints",
2048 name: "unnecessary_cast",
2049 group: "complexity",
2050 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2055 name: "unnecessary_filter_map",
2056 group: "complexity",
2057 desc: "using `filter_map` when a more succinct alternative exists",
2062 name: "unnecessary_fold",
2064 desc: "using `fold` when a more succinct alternative exists",
2069 name: "unnecessary_mut_passed",
2071 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2073 module: "mut_reference",
2076 name: "unnecessary_operation",
2077 group: "complexity",
2078 desc: "outer expressions with no effect",
2080 module: "no_effect",
2083 name: "unnecessary_unwrap",
2084 group: "complexity",
2085 desc: "checks for calls of unwrap[_err]() that cannot fail",
2090 name: "unneeded_field_pattern",
2092 desc: "struct fields bound to a wildcard instead of using `..`",
2094 module: "misc_early",
2097 name: "unneeded_wildcard_pattern",
2098 group: "complexity",
2099 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2101 module: "misc_early",
2104 name: "unreachable",
2105 group: "restriction",
2106 desc: "`unreachable!` should not be present in production code",
2108 module: "panic_unimplemented",
2111 name: "unreadable_literal",
2113 desc: "long integer literal without underscores",
2115 module: "literal_representation",
2118 name: "unsafe_removed_from_name",
2120 desc: "`unsafe` removed from API names on import",
2122 module: "unsafe_removed_from_name",
2125 name: "unseparated_literal_suffix",
2127 desc: "literals whose suffix is not separated by an underscore",
2129 module: "misc_early",
2132 name: "unsound_collection_transmute",
2133 group: "correctness",
2134 desc: "transmute between collections of layout-incompatible types",
2136 module: "transmute",
2139 name: "unused_io_amount",
2140 group: "correctness",
2141 desc: "unused written/read amount",
2143 module: "unused_io_amount",
2146 name: "unused_label",
2147 group: "complexity",
2148 desc: "unused labels",
2150 module: "unused_label",
2153 name: "unused_self",
2155 desc: "methods that contain a `self` argument but don\'t use it",
2157 module: "unused_self",
2160 name: "unused_unit",
2162 desc: "needless unit expression",
2168 group: "restriction",
2169 desc: "use of `Debug`-based formatting",
2176 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2181 name: "used_underscore_binding",
2183 desc: "using a binding which is prefixed with an underscore",
2188 name: "useless_asref",
2189 group: "complexity",
2190 desc: "using `as_ref` where the types before and after the call are the same",
2195 name: "useless_attribute",
2196 group: "correctness",
2197 desc: "use of lint attributes on `extern crate` items",
2202 name: "useless_format",
2203 group: "complexity",
2204 desc: "useless use of `format!`",
2209 name: "useless_let_if_seq",
2211 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2213 module: "let_if_seq",
2216 name: "useless_transmute",
2217 group: "complexity",
2218 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2220 module: "transmute",
2223 name: "useless_vec",
2225 desc: "useless `vec!`",
2231 group: "complexity",
2232 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2237 name: "verbose_bit_mask",
2239 desc: "expressions where a bit mask is less readable than the corresponding method call",
2244 name: "while_immutable_condition",
2245 group: "correctness",
2246 desc: "variables used within while expression are not mutated in the body",
2251 name: "while_let_loop",
2252 group: "complexity",
2253 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2258 name: "while_let_on_iterator",
2260 desc: "using a while-let loop instead of a for loop on an iterator",
2265 name: "wildcard_dependencies",
2267 desc: "wildcard dependencies being used",
2269 module: "wildcard_dependencies",
2272 name: "wildcard_enum_match_arm",
2273 group: "restriction",
2274 desc: "a wildcard enum match arm using `_`",
2279 name: "write_literal",
2281 desc: "writing a literal with a format string",
2286 name: "write_with_newline",
2288 desc: "using `write!()` with a format string that ends in a single newline",
2293 name: "writeln_empty_string",
2295 desc: "using `writeln!(buf, \"\")` with an empty string",
2300 name: "wrong_pub_self_convention",
2301 group: "restriction",
2302 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2307 name: "wrong_self_convention",
2309 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2314 name: "wrong_transmute",
2315 group: "correctness",
2316 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2318 module: "transmute",
2321 name: "zero_divided_by_zero",
2322 group: "complexity",
2323 desc: "usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN",
2325 module: "zero_div_zero",
2328 name: "zero_prefixed_literal",
2329 group: "complexity",
2330 desc: "integer literals starting with `0`",
2332 module: "misc_early",
2337 desc: "using 0 as *{const, mut} T",
2342 name: "zero_width_space",
2343 group: "correctness",
2344 desc: "using a zero-width space in a string literal, which is confusing",
2350 group: "correctness",
2351 desc: "Check for offset calculations on raw pointers to zero-sized types",
2356 // end lint list, do not remove this comment, it’s used in `update_lints`