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; 331] = [
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: "decimal_literal_representation",
285 group: "restriction",
286 desc: "using decimal representation when hexadecimal would be better",
288 module: "literal_representation",
291 name: "declare_interior_mutable_const",
292 group: "correctness",
293 desc: "declaring const with interior mutability",
295 module: "non_copy_const",
298 name: "default_trait_access",
300 desc: "checks for literal calls to Default::default()",
302 module: "default_trait_access",
305 name: "deprecated_cfg_attr",
307 desc: "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`",
312 name: "deprecated_semver",
313 group: "correctness",
314 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
319 name: "deref_addrof",
321 desc: "use of `*&` or `*&mut` in an expression",
326 name: "derive_hash_xor_eq",
327 group: "correctness",
328 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
333 name: "diverging_sub_expression",
335 desc: "whether an expression contains a diverging sub expression",
337 module: "eval_order_dependence",
340 name: "doc_markdown",
342 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
347 name: "double_comparisons",
349 desc: "unnecessary double comparisons that can be simplified",
351 module: "double_comparison",
354 name: "double_must_use",
356 desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method",
363 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
365 module: "misc_early",
368 name: "double_parens",
370 desc: "Warn on unnecessary double parentheses",
372 module: "double_parens",
376 group: "correctness",
377 desc: "Bounds of the form `T: Drop` are useless",
379 module: "drop_bounds",
383 group: "correctness",
384 desc: "calls to `std::mem::drop` with a value that implements Copy",
386 module: "drop_forget_ref",
390 group: "correctness",
391 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
393 module: "drop_forget_ref",
396 name: "duplicate_underscore_argument",
398 desc: "function arguments having names which only differ by an underscore",
400 module: "misc_early",
403 name: "duration_subsec",
405 desc: "checks for calculation of subsecond microseconds or milliseconds",
407 module: "duration_subsec",
410 name: "else_if_without_else",
411 group: "restriction",
412 desc: "if expression with an `else if`, but without a final `else` branch",
414 module: "else_if_without_else",
419 desc: "enum with no variants",
421 module: "empty_enum",
424 name: "empty_line_after_outer_attr",
426 desc: "empty line after outer attribute",
433 desc: "empty `loop {}`, which should block or sleep",
438 name: "enum_clike_unportable_variant",
439 group: "correctness",
440 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
442 module: "enum_clike",
445 name: "enum_glob_use",
447 desc: "use items that import all variants of an enum",
449 module: "enum_glob_use",
452 name: "enum_variant_names",
454 desc: "enums where all variants share a prefix/postfix",
456 module: "enum_variants",
460 group: "correctness",
461 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
467 group: "correctness",
468 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
470 module: "erasing_op",
473 name: "eval_order_dependence",
475 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
477 module: "eval_order_dependence",
480 name: "excessive_precision",
482 desc: "excessive precision for float literal",
484 module: "excessive_precision",
487 name: "expect_fun_call",
489 desc: "using any `expect` method with a function call",
494 name: "expl_impl_clone_on_copy",
496 desc: "implementing `Clone` explicitly on `Copy` types",
501 name: "explicit_counter_loop",
503 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
508 name: "explicit_into_iter_loop",
510 desc: "for-looping over `_.into_iter()` when `_` would do",
515 name: "explicit_iter_loop",
517 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
522 name: "explicit_write",
524 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
526 module: "explicit_write",
529 name: "extra_unused_lifetimes",
531 desc: "unused lifetimes in function definitions",
536 name: "fallible_impl_from",
538 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
540 module: "fallible_impl_from",
545 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
550 name: "filter_map_next",
552 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
559 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
566 desc: "using a combination of `find` and `map` can usually be written as a single method call",
571 name: "flat_map_identity",
573 desc: "call to `flat_map` where `flatten` is sufficient",
578 name: "float_arithmetic",
579 group: "restriction",
580 desc: "any floating-point arithmetic statement",
582 module: "arithmetic",
586 group: "correctness",
587 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
592 name: "float_cmp_const",
593 group: "restriction",
594 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
599 name: "fn_to_numeric_cast",
601 desc: "casting a function pointer to a numeric type other than usize",
606 name: "fn_to_numeric_cast_with_truncation",
608 desc: "casting a function pointer to a numeric type not wide enough to store the address",
615 desc: "looping on a map using `iter` when `keys` or `values` would do",
620 name: "for_loop_over_option",
621 group: "correctness",
622 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
627 name: "for_loop_over_result",
628 group: "correctness",
629 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
635 group: "correctness",
636 desc: "calls to `std::mem::forget` with a value that implements Copy",
638 module: "drop_forget_ref",
642 group: "correctness",
643 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
645 module: "drop_forget_ref",
648 name: "get_last_with_len",
650 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
652 module: "get_last_with_len",
656 group: "restriction",
657 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
662 name: "identity_conversion",
664 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
666 module: "identity_conversion",
671 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
673 module: "identity_op",
676 name: "if_let_some_result",
678 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
685 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
687 module: "if_not_else",
690 name: "if_same_then_else",
691 group: "correctness",
692 desc: "if with the same *then* and *else* blocks",
697 name: "ifs_same_cond",
698 group: "correctness",
699 desc: "consecutive `ifs` with the same condition",
704 name: "implicit_hasher",
706 desc: "missing generalization over different hashers",
711 name: "implicit_return",
712 group: "restriction",
713 desc: "use a return statement like `return expr` instead of an expression",
715 module: "implicit_return",
718 name: "inconsistent_digit_grouping",
720 desc: "integer literals with digits grouped inconsistently",
722 module: "literal_representation",
725 name: "indexing_slicing",
726 group: "restriction",
727 desc: "indexing/slicing usage",
729 module: "indexing_slicing",
732 name: "ineffective_bit_mask",
733 group: "correctness",
734 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
739 name: "inefficient_to_string",
741 desc: "using `to_string` on `&&T` where `T: ToString`",
746 name: "infallible_destructuring_match",
748 desc: "a match statement with a single infallible arm instead of a `let`",
750 module: "infallible_destructuring_match",
753 name: "infinite_iter",
754 group: "correctness",
755 desc: "infinite iteration",
757 module: "infinite_iter",
760 name: "inherent_to_string",
762 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
764 module: "inherent_to_string",
767 name: "inherent_to_string_shadow_display",
768 group: "correctness",
769 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait ",
771 module: "inherent_to_string",
774 name: "inline_always",
776 desc: "use of `#[inline(always)]`",
781 name: "inline_fn_without_body",
782 group: "correctness",
783 desc: "use of `#[inline]` on trait methods without bodies",
785 module: "inline_fn_without_body",
788 name: "int_plus_one",
790 desc: "instead of using x >= y + 1, use x > y",
792 module: "int_plus_one",
795 name: "integer_arithmetic",
796 group: "restriction",
797 desc: "any integer arithmetic statement",
799 module: "arithmetic",
802 name: "integer_division",
803 group: "restriction",
804 desc: "integer division may cause loss of precision",
806 module: "integer_division",
809 name: "into_iter_on_array",
810 group: "correctness",
811 desc: "using `.into_iter()` on an array",
816 name: "into_iter_on_ref",
818 desc: "using `.into_iter()` on a reference",
823 name: "invalid_regex",
824 group: "correctness",
825 desc: "invalid regular expressions",
830 name: "invalid_upcast_comparisons",
832 desc: "a comparison involving an upcast which is always true or false",
837 name: "items_after_statements",
839 desc: "blocks where an item comes after a statement",
841 module: "items_after_statements",
844 name: "iter_cloned_collect",
846 desc: "using `.cloned().collect()` on slice to create a `Vec`",
851 name: "iter_next_loop",
852 group: "correctness",
853 desc: "for-looping over `_.next()` which is probably not intended",
860 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
865 name: "iter_skip_next",
867 desc: "using `.skip(x).next()` on an iterator",
872 name: "iterator_step_by_zero",
873 group: "correctness",
874 desc: "using `Iterator::step_by(0)`, which produces an infinite iterator",
879 name: "just_underscores_and_digits",
881 desc: "unclear name",
883 module: "non_expressive_names",
886 name: "large_digit_groups",
888 desc: "grouping digits into groups that are too large",
890 module: "literal_representation",
893 name: "large_enum_variant",
895 desc: "large size difference between variants on an enum",
897 module: "large_enum_variant",
900 name: "len_without_is_empty",
902 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
909 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
914 name: "let_and_return",
916 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
921 name: "let_unit_value",
923 desc: "creating a let binding to a value of unit type, which usually can\'t be used afterwards",
930 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a VecDeque",
936 group: "correctness",
937 desc: "boolean expressions that contain terminals which can be eliminated",
942 name: "main_recursion",
944 desc: "recursion using the entrypoint",
946 module: "main_recursion",
949 name: "manual_memcpy",
951 desc: "manually copying items between slices",
956 name: "manual_mul_add",
958 desc: "Using `a.mul_add(b, c)` for floating points has higher numerical precision than `a * b + c`",
963 name: "manual_saturating_arithmetic",
965 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
972 desc: "manual swap of two variables",
977 name: "many_single_char_names",
979 desc: "too many single character bindings",
981 module: "non_expressive_names",
986 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
993 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1000 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1005 name: "match_as_ref",
1006 group: "complexity",
1007 desc: "a match on an Option value instead of using `as_ref()` or `as_mut`",
1014 desc: "a match on a boolean expression instead of an `if..else` block",
1019 name: "match_overlapping_arm",
1021 desc: "a match with overlapping arms",
1026 name: "match_ref_pats",
1028 desc: "a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1033 name: "match_same_arms",
1035 desc: "`match` with identical arm bodies",
1040 name: "match_wild_err_arm",
1042 desc: "a match with `Err(_)` arm and take drastic actions",
1047 name: "maybe_infinite_iter",
1049 desc: "possible infinite iteration",
1051 module: "infinite_iter",
1054 name: "mem_discriminant_non_enum",
1055 group: "correctness",
1056 desc: "calling mem::descriminant on non-enum type",
1058 module: "mem_discriminant",
1062 group: "restriction",
1063 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1065 module: "mem_forget",
1068 name: "mem_replace_option_with_none",
1070 desc: "replacing an `Option` with `None` instead of `take()`",
1072 module: "mem_replace",
1075 name: "mem_replace_with_uninit",
1076 group: "correctness",
1077 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1079 module: "mem_replace",
1083 group: "correctness",
1084 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1089 name: "misrefactored_assign_op",
1090 group: "complexity",
1091 desc: "having a variable on both sides of an assign op",
1093 module: "assign_ops",
1096 name: "missing_const_for_fn",
1098 desc: "Lint functions definitions that could be made `const fn`",
1100 module: "missing_const_for_fn",
1103 name: "missing_docs_in_private_items",
1104 group: "restriction",
1105 desc: "detects missing documentation for public and private members",
1107 module: "missing_doc",
1110 name: "missing_inline_in_public_items",
1111 group: "restriction",
1112 desc: "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)",
1114 module: "missing_inline",
1117 name: "missing_safety_doc",
1119 desc: "`pub unsafe fn` without `# Safety` docs",
1124 name: "mistyped_literal_suffixes",
1125 group: "correctness",
1126 desc: "mistyped literal suffix",
1128 module: "literal_representation",
1131 name: "mixed_case_hex_literals",
1133 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1135 module: "misc_early",
1138 name: "module_inception",
1140 desc: "modules that have the same name as their parent module",
1142 module: "enum_variants",
1145 name: "module_name_repetitions",
1147 desc: "type names prefixed/postfixed with their containing module\'s name",
1149 module: "enum_variants",
1153 group: "correctness",
1154 desc: "taking a number modulo 1, which always returns 0",
1159 name: "multiple_crate_versions",
1161 desc: "multiple versions of the same crate being used",
1163 module: "multiple_crate_versions",
1166 name: "multiple_inherent_impl",
1167 group: "restriction",
1168 desc: "Multiple inherent impl that could be grouped",
1170 module: "inherent_impl",
1173 name: "must_use_candidate",
1175 desc: "function or method that could take a `#[must_use]` attribute",
1177 module: "functions",
1180 name: "must_use_unit",
1182 desc: "`#[must_use]` attribute on a unit-returning function / method",
1184 module: "functions",
1187 name: "mut_from_ref",
1188 group: "correctness",
1189 desc: "fns that create mutable refs from immutable ref args",
1196 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1201 name: "mut_range_bound",
1202 group: "complexity",
1203 desc: "for loop over a range where one of the bounds is a mutable variable",
1208 name: "mutex_atomic",
1210 desc: "using a mutex where an atomic value could be used instead",
1212 module: "mutex_atomic",
1215 name: "mutex_integer",
1217 desc: "using a mutex for an integer type",
1219 module: "mutex_atomic",
1222 name: "naive_bytecount",
1224 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1226 module: "bytecount",
1229 name: "needless_bool",
1230 group: "complexity",
1231 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1233 module: "needless_bool",
1236 name: "needless_borrow",
1238 desc: "taking a reference that is going to be automatically dereferenced",
1240 module: "needless_borrow",
1243 name: "needless_borrowed_reference",
1244 group: "complexity",
1245 desc: "taking a needless borrowed reference",
1247 module: "needless_borrowed_ref",
1250 name: "needless_collect",
1252 desc: "collecting an iterator when collect is not needed",
1257 name: "needless_continue",
1259 desc: "`continue` statements that can be replaced by a rearrangement of code",
1261 module: "needless_continue",
1264 name: "needless_doctest_main",
1266 desc: "presence of `fn main() {` in code examples",
1271 name: "needless_lifetimes",
1272 group: "complexity",
1273 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1275 module: "lifetimes",
1278 name: "needless_pass_by_value",
1280 desc: "functions taking arguments by value, but not consuming them in its body",
1282 module: "needless_pass_by_value",
1285 name: "needless_range_loop",
1287 desc: "for-looping over a range of indices where an iterator over items would do",
1292 name: "needless_return",
1294 desc: "using a return statement like `return expr;` where an expression would suffice",
1299 name: "needless_update",
1300 group: "complexity",
1301 desc: "using `Foo { ..base }` when there are no missing fields",
1303 module: "needless_update",
1306 name: "neg_cmp_op_on_partial_ord",
1307 group: "complexity",
1308 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1310 module: "neg_cmp_op_on_partial_ord",
1313 name: "neg_multiply",
1315 desc: "multiplying integers with -1",
1317 module: "neg_multiply",
1321 group: "correctness",
1322 desc: "any loop that will always `break` or `return`",
1327 name: "new_ret_no_self",
1329 desc: "not returning `Self` in a `new` method",
1334 name: "new_without_default",
1336 desc: "`fn new() -> Self` method without `Default` implementation",
1338 module: "new_without_default",
1342 group: "complexity",
1343 desc: "statements with no effect",
1345 module: "no_effect",
1348 name: "non_ascii_literal",
1350 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1355 name: "nonminimal_bool",
1356 group: "complexity",
1357 desc: "boolean expressions that can be written more concisely",
1362 name: "nonsensical_open_options",
1363 group: "correctness",
1364 desc: "nonsensical combination of options for opening a file",
1366 module: "open_options",
1369 name: "not_unsafe_ptr_arg_deref",
1370 group: "correctness",
1371 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1373 module: "functions",
1378 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1385 desc: "taking a reference to satisfy the type constraints on `==`",
1390 name: "option_and_then_some",
1391 group: "complexity",
1392 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1397 name: "option_expect_used",
1398 group: "restriction",
1399 desc: "using `Option.expect()`, which might be better handled",
1404 name: "option_map_or_none",
1406 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1411 name: "option_map_unit_fn",
1412 group: "complexity",
1413 desc: "using `option.map(f)`, where f is a function or closure that returns ()",
1415 module: "map_unit_fn",
1418 name: "option_map_unwrap_or",
1420 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1425 name: "option_map_unwrap_or_else",
1427 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1432 name: "option_option",
1433 group: "complexity",
1434 desc: "usage of `Option<Option<T>>`",
1439 name: "option_unwrap_used",
1440 group: "restriction",
1441 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1446 name: "or_fun_call",
1448 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1453 name: "out_of_bounds_indexing",
1454 group: "correctness",
1455 desc: "out of bounds constant indexing",
1457 module: "indexing_slicing",
1460 name: "overflow_check_conditional",
1461 group: "complexity",
1462 desc: "overflow checks inspired by C which are likely to panic",
1464 module: "overflow_check_conditional",
1468 group: "restriction",
1469 desc: "usage of the `panic!` macro",
1471 module: "panic_unimplemented",
1474 name: "panic_params",
1476 desc: "missing parameters in `panic!` calls",
1478 module: "panic_unimplemented",
1481 name: "panicking_unwrap",
1482 group: "correctness",
1483 desc: "checks for calls of unwrap[_err]() that will always fail",
1488 name: "partialeq_ne_impl",
1489 group: "complexity",
1490 desc: "re-implementing `PartialEq::ne`",
1492 module: "partialeq_ne_impl",
1495 name: "path_buf_push_overwrite",
1497 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1499 module: "path_buf_push_overwrite",
1502 name: "possible_missing_comma",
1503 group: "correctness",
1504 desc: "possible missing comma in array",
1506 module: "formatting",
1510 group: "complexity",
1511 desc: "operations where precedence may be unclear",
1513 module: "precedence",
1516 name: "print_literal",
1518 desc: "printing a literal with a format string",
1523 name: "print_stdout",
1524 group: "restriction",
1525 desc: "printing on stdout",
1530 name: "print_with_newline",
1532 desc: "using `print!()` with a format string that ends in a single newline",
1537 name: "println_empty_string",
1539 desc: "using `println!(\"\")` with an empty string",
1546 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1551 name: "ptr_offset_with_cast",
1552 group: "complexity",
1553 desc: "unneeded pointer offset cast",
1555 module: "ptr_offset_with_cast",
1558 name: "pub_enum_variant_names",
1560 desc: "enums where all variants share a prefix/postfix",
1562 module: "enum_variants",
1565 name: "question_mark",
1567 desc: "checks for expressions that could be replaced by the question mark operator",
1569 module: "question_mark",
1572 name: "range_minus_one",
1573 group: "complexity",
1574 desc: "`x..=(y-1)` reads better as `x..y`",
1579 name: "range_plus_one",
1580 group: "complexity",
1581 desc: "`x..(y+1)` reads better as `x..=y`",
1586 name: "range_zip_with_len",
1587 group: "complexity",
1588 desc: "zipping iterator with a range when `enumerate()` would do",
1593 name: "redundant_clone",
1595 desc: "`clone()` of an owned value that is going to be dropped immediately",
1597 module: "redundant_clone",
1600 name: "redundant_closure",
1602 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1604 module: "eta_reduction",
1607 name: "redundant_closure_call",
1608 group: "complexity",
1609 desc: "throwaway closures called in the expression they are defined",
1611 module: "misc_early",
1614 name: "redundant_closure_for_method_calls",
1616 desc: "redundant closures for method calls",
1618 module: "eta_reduction",
1621 name: "redundant_field_names",
1623 desc: "checks for fields in struct literals where shorthands could be used",
1625 module: "redundant_field_names",
1628 name: "redundant_pattern",
1630 desc: "using `name @ _` in a pattern",
1632 module: "misc_early",
1635 name: "redundant_pattern_matching",
1637 desc: "use the proper utility function avoiding an `if let`",
1639 module: "redundant_pattern_matching",
1642 name: "redundant_static_lifetimes",
1644 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1646 module: "redundant_static_lifetimes",
1649 name: "ref_in_deref",
1650 group: "complexity",
1651 desc: "Use of reference in auto dereference expression.",
1653 module: "reference",
1656 name: "regex_macro",
1658 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1663 name: "replace_consts",
1665 desc: "Lint usages of standard library `const`s that could be replaced by `const fn`s",
1667 module: "replace_consts",
1670 name: "result_expect_used",
1671 group: "restriction",
1672 desc: "using `Result.expect()`, which might be better handled",
1677 name: "result_map_unit_fn",
1678 group: "complexity",
1679 desc: "using `result.map(f)`, where f is a function or closure that returns ()",
1681 module: "map_unit_fn",
1684 name: "result_map_unwrap_or_else",
1686 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.ok().map_or_else(g, f)`",
1691 name: "result_unwrap_used",
1692 group: "restriction",
1693 desc: "using `Result.unwrap()`, which might be better handled",
1698 name: "reverse_range_loop",
1699 group: "correctness",
1700 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1705 name: "search_is_some",
1706 group: "complexity",
1707 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1712 name: "serde_api_misuse",
1713 group: "correctness",
1714 desc: "various things that will negatively affect your serde experience",
1716 module: "serde_api",
1719 name: "shadow_reuse",
1720 group: "restriction",
1721 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1726 name: "shadow_same",
1727 group: "restriction",
1728 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1733 name: "shadow_unrelated",
1735 desc: "rebinding a name without even using the original value",
1740 name: "short_circuit_statement",
1741 group: "complexity",
1742 desc: "using a short circuit boolean condition as a statement",
1747 name: "should_implement_trait",
1749 desc: "defining a method that should be implementing a std trait",
1754 name: "similar_names",
1756 desc: "similarly named items and bindings",
1758 module: "non_expressive_names",
1761 name: "single_char_pattern",
1763 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1768 name: "single_match",
1770 desc: "a match statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1775 name: "single_match_else",
1777 desc: "a match statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1782 name: "slow_vector_initialization",
1784 desc: "slow vector initialization",
1786 module: "slow_vector_initialization",
1790 group: "restriction",
1791 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1796 name: "string_add_assign",
1798 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1803 name: "string_extend_chars",
1805 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1810 name: "string_lit_as_bytes",
1812 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1817 name: "suspicious_arithmetic_impl",
1818 group: "correctness",
1819 desc: "suspicious use of operators in impl of arithmetic trait",
1821 module: "suspicious_trait_impl",
1824 name: "suspicious_assignment_formatting",
1826 desc: "suspicious formatting of `*=`, `-=` or `!=`",
1828 module: "formatting",
1831 name: "suspicious_else_formatting",
1833 desc: "suspicious formatting of `else`",
1835 module: "formatting",
1838 name: "suspicious_map",
1839 group: "complexity",
1840 desc: "suspicious usage of map",
1845 name: "suspicious_op_assign_impl",
1846 group: "correctness",
1847 desc: "suspicious use of operators in impl of OpAssign trait",
1849 module: "suspicious_trait_impl",
1852 name: "suspicious_unary_op_formatting",
1854 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
1856 module: "formatting",
1859 name: "temporary_assignment",
1860 group: "complexity",
1861 desc: "assignments to temporaries",
1863 module: "temporary_assignment",
1866 name: "temporary_cstring_as_ptr",
1867 group: "correctness",
1868 desc: "getting the inner pointer of a temporary `CString`",
1874 group: "restriction",
1875 desc: "`todo!` should not be present in production code",
1877 module: "panic_unimplemented",
1880 name: "too_many_arguments",
1881 group: "complexity",
1882 desc: "functions with too many arguments",
1884 module: "functions",
1887 name: "too_many_lines",
1889 desc: "functions with too many lines",
1891 module: "functions",
1894 name: "toplevel_ref_arg",
1896 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
1901 name: "transmute_bytes_to_str",
1902 group: "complexity",
1903 desc: "transmutes from a `&[u8]` to a `&str`",
1905 module: "transmute",
1908 name: "transmute_int_to_bool",
1909 group: "complexity",
1910 desc: "transmutes from an integer to a `bool`",
1912 module: "transmute",
1915 name: "transmute_int_to_char",
1916 group: "complexity",
1917 desc: "transmutes from an integer to a `char`",
1919 module: "transmute",
1922 name: "transmute_int_to_float",
1923 group: "complexity",
1924 desc: "transmutes from an integer to a float",
1926 module: "transmute",
1929 name: "transmute_ptr_to_ptr",
1930 group: "complexity",
1931 desc: "transmutes from a pointer to a pointer / a reference to a reference",
1933 module: "transmute",
1936 name: "transmute_ptr_to_ref",
1937 group: "complexity",
1938 desc: "transmutes from a pointer to a reference type",
1940 module: "transmute",
1943 name: "transmuting_null",
1944 group: "correctness",
1945 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
1947 module: "transmuting_null",
1950 name: "trivial_regex",
1952 desc: "trivial regular expressions",
1957 name: "trivially_copy_pass_by_ref",
1959 desc: "functions taking small copyable arguments by reference",
1961 module: "trivially_copy_pass_by_ref",
1966 desc: "return errors explicitly rather than hiding them behind a `?`",
1971 name: "type_complexity",
1972 group: "complexity",
1973 desc: "usage of very complex types that might be better factored into `type` definitions",
1978 name: "type_repetition_in_bounds",
1980 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
1982 module: "trait_bounds",
1985 name: "unicode_not_nfc",
1987 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
1992 name: "unimplemented",
1993 group: "restriction",
1994 desc: "`unimplemented!` should not be present in production code",
1996 module: "panic_unimplemented",
1999 name: "uninit_assumed_init",
2000 group: "correctness",
2001 desc: "`MaybeUninit::uninit().assume_init()`",
2007 group: "complexity",
2008 desc: "passing unit to a function",
2014 group: "correctness",
2015 desc: "comparing unit values",
2020 name: "unknown_clippy_lints",
2022 desc: "unknown_lints for scoped Clippy lints",
2027 name: "unnecessary_cast",
2028 group: "complexity",
2029 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2034 name: "unnecessary_filter_map",
2035 group: "complexity",
2036 desc: "using `filter_map` when a more succinct alternative exists",
2041 name: "unnecessary_fold",
2043 desc: "using `fold` when a more succinct alternative exists",
2048 name: "unnecessary_mut_passed",
2050 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2052 module: "mut_reference",
2055 name: "unnecessary_operation",
2056 group: "complexity",
2057 desc: "outer expressions with no effect",
2059 module: "no_effect",
2062 name: "unnecessary_unwrap",
2063 group: "complexity",
2064 desc: "checks for calls of unwrap[_err]() that cannot fail",
2069 name: "unneeded_field_pattern",
2071 desc: "struct fields bound to a wildcard instead of using `..`",
2073 module: "misc_early",
2076 name: "unneeded_wildcard_pattern",
2077 group: "complexity",
2078 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2080 module: "misc_early",
2083 name: "unreachable",
2084 group: "restriction",
2085 desc: "`unreachable!` should not be present in production code",
2087 module: "panic_unimplemented",
2090 name: "unreadable_literal",
2092 desc: "long integer literal without underscores",
2094 module: "literal_representation",
2097 name: "unsafe_removed_from_name",
2099 desc: "`unsafe` removed from API names on import",
2101 module: "unsafe_removed_from_name",
2104 name: "unseparated_literal_suffix",
2106 desc: "literals whose suffix is not separated by an underscore",
2108 module: "misc_early",
2111 name: "unsound_collection_transmute",
2112 group: "correctness",
2113 desc: "transmute between collections of layout-incompatible types",
2115 module: "transmute",
2118 name: "unused_io_amount",
2119 group: "correctness",
2120 desc: "unused written/read amount",
2122 module: "unused_io_amount",
2125 name: "unused_label",
2126 group: "complexity",
2127 desc: "unused labels",
2129 module: "unused_label",
2132 name: "unused_self",
2134 desc: "methods that contain a `self` argument but don\'t use it",
2136 module: "unused_self",
2139 name: "unused_unit",
2141 desc: "needless unit expression",
2147 group: "restriction",
2148 desc: "use of `Debug`-based formatting",
2155 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2160 name: "used_underscore_binding",
2162 desc: "using a binding which is prefixed with an underscore",
2167 name: "useless_asref",
2168 group: "complexity",
2169 desc: "using `as_ref` where the types before and after the call are the same",
2174 name: "useless_attribute",
2175 group: "correctness",
2176 desc: "use of lint attributes on `extern crate` items",
2181 name: "useless_format",
2182 group: "complexity",
2183 desc: "useless use of `format!`",
2188 name: "useless_let_if_seq",
2190 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2192 module: "let_if_seq",
2195 name: "useless_transmute",
2196 group: "complexity",
2197 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2199 module: "transmute",
2202 name: "useless_vec",
2204 desc: "useless `vec!`",
2210 group: "complexity",
2211 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2216 name: "verbose_bit_mask",
2218 desc: "expressions where a bit mask is less readable than the corresponding method call",
2223 name: "while_immutable_condition",
2224 group: "correctness",
2225 desc: "variables used within while expression are not mutated in the body",
2230 name: "while_let_loop",
2231 group: "complexity",
2232 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2237 name: "while_let_on_iterator",
2239 desc: "using a while-let loop instead of a for loop on an iterator",
2244 name: "wildcard_dependencies",
2246 desc: "wildcard dependencies being used",
2248 module: "wildcard_dependencies",
2251 name: "wildcard_enum_match_arm",
2252 group: "restriction",
2253 desc: "a wildcard enum match arm using `_`",
2258 name: "write_literal",
2260 desc: "writing a literal with a format string",
2265 name: "write_with_newline",
2267 desc: "using `write!()` with a format string that ends in a single newline",
2272 name: "writeln_empty_string",
2274 desc: "using `writeln!(buf, \"\")` with an empty string",
2279 name: "wrong_pub_self_convention",
2280 group: "restriction",
2281 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2286 name: "wrong_self_convention",
2288 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2293 name: "wrong_transmute",
2294 group: "correctness",
2295 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2297 module: "transmute",
2300 name: "zero_divided_by_zero",
2301 group: "complexity",
2302 desc: "usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN",
2304 module: "zero_div_zero",
2307 name: "zero_prefixed_literal",
2308 group: "complexity",
2309 desc: "integer literals starting with `0`",
2311 module: "misc_early",
2316 desc: "using 0 as *{const, mut} T",
2321 name: "zero_width_space",
2322 group: "correctness",
2323 desc: "using a zero-width space in a string literal, which is confusing",
2328 // end lint list, do not remove this comment, it’s used in `update_lints`