1 //! This file is managed by `cargo 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; 363] = [
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",
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: "wildcard_imports",
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: "float_literal",
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",
564 name: "filetype_is_file",
565 group: "restriction",
566 desc: "`FileType::is_file` is not recommended to test for readable file type",
573 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
578 name: "filter_map_next",
580 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
587 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
594 desc: "using a combination of `find` and `map` can usually be written as a single method call",
599 name: "flat_map_identity",
601 desc: "call to `flat_map` where `flatten` is sufficient",
606 name: "float_arithmetic",
607 group: "restriction",
608 desc: "any floating-point arithmetic statement",
610 module: "arithmetic",
614 group: "correctness",
615 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
620 name: "float_cmp_const",
621 group: "restriction",
622 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
627 name: "fn_address_comparisons",
628 group: "correctness",
629 desc: "comparison with an address of a function item",
631 module: "unnamed_address",
634 name: "fn_params_excessive_bools",
636 desc: "using too many bools in function parameters",
638 module: "excessive_bools",
641 name: "fn_to_numeric_cast",
643 desc: "casting a function pointer to a numeric type other than usize",
648 name: "fn_to_numeric_cast_with_truncation",
650 desc: "casting a function pointer to a numeric type not wide enough to store the address",
657 desc: "looping on a map using `iter` when `keys` or `values` would do",
662 name: "for_loop_over_option",
663 group: "correctness",
664 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
669 name: "for_loop_over_result",
670 group: "correctness",
671 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
677 group: "correctness",
678 desc: "calls to `std::mem::forget` with a value that implements Copy",
680 module: "drop_forget_ref",
684 group: "correctness",
685 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
687 module: "drop_forget_ref",
690 name: "get_last_with_len",
692 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
694 module: "get_last_with_len",
698 group: "restriction",
699 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
704 name: "identity_conversion",
706 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
708 module: "identity_conversion",
713 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
715 module: "identity_op",
718 name: "if_let_some_result",
720 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
722 module: "if_let_some_result",
727 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
729 module: "if_not_else",
732 name: "if_same_then_else",
733 group: "correctness",
734 desc: "`if` with the same `then` and `else` blocks",
739 name: "ifs_same_cond",
740 group: "correctness",
741 desc: "consecutive `if`s with the same condition",
746 name: "implicit_hasher",
748 desc: "missing generalization over different hashers",
753 name: "implicit_return",
754 group: "restriction",
755 desc: "use a return statement like `return expr` instead of an expression",
757 module: "implicit_return",
760 name: "imprecise_flops",
762 desc: "usage of imprecise floating point operations",
764 module: "floating_point_arithmetic",
767 name: "inconsistent_digit_grouping",
769 desc: "integer literals with digits grouped inconsistently",
771 module: "literal_representation",
774 name: "indexing_slicing",
775 group: "restriction",
776 desc: "indexing/slicing usage",
778 module: "indexing_slicing",
781 name: "ineffective_bit_mask",
782 group: "correctness",
783 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
788 name: "inefficient_to_string",
790 desc: "using `to_string` on `&&T` where `T: ToString`",
795 name: "infallible_destructuring_match",
797 desc: "a `match` statement with a single infallible arm instead of a `let`",
802 name: "infinite_iter",
803 group: "correctness",
804 desc: "infinite iteration",
806 module: "infinite_iter",
809 name: "inherent_to_string",
811 desc: "type implements inherent method `to_string()`, but should instead implement the `Display` trait",
813 module: "inherent_to_string",
816 name: "inherent_to_string_shadow_display",
817 group: "correctness",
818 desc: "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait",
820 module: "inherent_to_string",
823 name: "inline_always",
825 desc: "use of `#[inline(always)]`",
830 name: "inline_fn_without_body",
831 group: "correctness",
832 desc: "use of `#[inline]` on trait methods without bodies",
834 module: "inline_fn_without_body",
837 name: "int_plus_one",
839 desc: "instead of using `x >= y + 1`, use `x > y`",
841 module: "int_plus_one",
844 name: "integer_arithmetic",
845 group: "restriction",
846 desc: "any integer arithmetic statement",
848 module: "arithmetic",
851 name: "integer_division",
852 group: "restriction",
853 desc: "integer division may cause loss of precision",
855 module: "integer_division",
858 name: "into_iter_on_ref",
860 desc: "using `.into_iter()` on a reference",
865 name: "invalid_atomic_ordering",
866 group: "correctness",
867 desc: "usage of invalid atomic ordering in atomic loads/stores and memory fences",
869 module: "atomic_ordering",
872 name: "invalid_regex",
873 group: "correctness",
874 desc: "invalid regular expressions",
879 name: "invalid_upcast_comparisons",
881 desc: "a comparison involving an upcast which is always true or false",
886 name: "items_after_statements",
888 desc: "blocks where an item comes after a statement",
890 module: "items_after_statements",
893 name: "iter_cloned_collect",
895 desc: "using `.cloned().collect()` on slice to create a `Vec`",
900 name: "iter_next_loop",
901 group: "correctness",
902 desc: "for-looping over `_.next()` which is probably not intended",
909 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
914 name: "iter_nth_zero",
916 desc: "replace `iter.nth(0)` with `iter.next()`",
921 name: "iter_skip_next",
923 desc: "using `.skip(x).next()` on an iterator",
928 name: "iterator_step_by_zero",
929 group: "correctness",
930 desc: "using `Iterator::step_by(0)`, which will panic at runtime",
935 name: "just_underscores_and_digits",
937 desc: "unclear name",
939 module: "non_expressive_names",
942 name: "large_digit_groups",
944 desc: "grouping digits into groups that are too large",
946 module: "literal_representation",
949 name: "large_enum_variant",
951 desc: "large size difference between variants on an enum",
953 module: "large_enum_variant",
956 name: "large_stack_arrays",
958 desc: "allocating large arrays on stack may cause stack overflow",
960 module: "large_stack_arrays",
963 name: "len_without_is_empty",
965 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
972 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
977 name: "let_and_return",
979 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
984 name: "let_underscore_lock",
985 group: "correctness",
986 desc: "non-binding let on a synchronization lock",
988 module: "let_underscore",
991 name: "let_underscore_must_use",
992 group: "restriction",
993 desc: "non-binding let on a `#[must_use]` expression",
995 module: "let_underscore",
998 name: "let_unit_value",
1000 desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
1007 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`",
1013 group: "correctness",
1014 desc: "boolean expressions that contain terminals which can be eliminated",
1019 name: "lossy_float_literal",
1020 group: "restriction",
1021 desc: "lossy whole number float literals",
1023 module: "float_literal",
1026 name: "macro_use_imports",
1028 desc: "#[macro_use] is no longer needed",
1030 module: "macro_use",
1033 name: "main_recursion",
1035 desc: "recursion using the entrypoint",
1037 module: "main_recursion",
1040 name: "manual_memcpy",
1042 desc: "manually copying items between slices",
1047 name: "manual_saturating_arithmetic",
1049 desc: "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`",
1054 name: "manual_swap",
1055 group: "complexity",
1056 desc: "manual swap of two variables",
1061 name: "many_single_char_names",
1063 desc: "too many single character bindings",
1065 module: "non_expressive_names",
1070 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
1072 module: "map_clone",
1077 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
1082 name: "map_flatten",
1084 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
1089 name: "match_as_ref",
1090 group: "complexity",
1091 desc: "a `match` on an Option value instead of using `as_ref()` or `as_mut`",
1098 desc: "a `match` on a boolean expression instead of an `if..else` block",
1103 name: "match_overlapping_arm",
1105 desc: "a `match` with overlapping arms",
1110 name: "match_ref_pats",
1112 desc: "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
1117 name: "match_same_arms",
1119 desc: "`match` with identical arm bodies",
1124 name: "match_single_binding",
1125 group: "complexity",
1126 desc: "a match with a single binding instead of using `let` statement",
1131 name: "match_wild_err_arm",
1133 desc: "a `match` with `Err(_)` arm and take drastic actions",
1138 name: "maybe_infinite_iter",
1140 desc: "possible infinite iteration",
1142 module: "infinite_iter",
1145 name: "mem_discriminant_non_enum",
1146 group: "correctness",
1147 desc: "calling `mem::descriminant` on non-enum type",
1149 module: "mem_discriminant",
1153 group: "restriction",
1154 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1156 module: "mem_forget",
1159 name: "mem_replace_option_with_none",
1161 desc: "replacing an `Option` with `None` instead of `take()`",
1163 module: "mem_replace",
1166 name: "mem_replace_with_default",
1168 desc: "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`",
1170 module: "mem_replace",
1173 name: "mem_replace_with_uninit",
1174 group: "correctness",
1175 desc: "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`",
1177 module: "mem_replace",
1181 group: "correctness",
1182 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1187 name: "misrefactored_assign_op",
1188 group: "complexity",
1189 desc: "having a variable on both sides of an assign op",
1191 module: "assign_ops",
1194 name: "missing_const_for_fn",
1196 desc: "Lint functions definitions that could be made `const fn`",
1198 module: "missing_const_for_fn",
1201 name: "missing_docs_in_private_items",
1202 group: "restriction",
1203 desc: "detects missing documentation for public and private members",
1205 module: "missing_doc",
1208 name: "missing_errors_doc",
1210 desc: "`pub fn` returns `Result` without `# Errors` in doc comment",
1215 name: "missing_inline_in_public_items",
1216 group: "restriction",
1217 desc: "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)",
1219 module: "missing_inline",
1222 name: "missing_safety_doc",
1224 desc: "`pub unsafe fn` without `# Safety` docs",
1229 name: "mistyped_literal_suffixes",
1230 group: "correctness",
1231 desc: "mistyped literal suffix",
1233 module: "literal_representation",
1236 name: "mixed_case_hex_literals",
1238 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1240 module: "misc_early",
1243 name: "module_inception",
1245 desc: "modules that have the same name as their parent module",
1247 module: "enum_variants",
1250 name: "module_name_repetitions",
1252 desc: "type names prefixed/postfixed with their containing module\'s name",
1254 module: "enum_variants",
1257 name: "modulo_arithmetic",
1258 group: "restriction",
1259 desc: "any modulo arithmetic statement",
1261 module: "modulo_arithmetic",
1265 group: "correctness",
1266 desc: "taking a number modulo 1, which always returns 0",
1271 name: "multiple_crate_versions",
1273 desc: "multiple versions of the same crate being used",
1275 module: "multiple_crate_versions",
1278 name: "multiple_inherent_impl",
1279 group: "restriction",
1280 desc: "Multiple inherent impl that could be grouped",
1282 module: "inherent_impl",
1285 name: "must_use_candidate",
1287 desc: "function or method that could take a `#[must_use]` attribute",
1289 module: "functions",
1292 name: "must_use_unit",
1294 desc: "`#[must_use]` attribute on a unit-returning function / method",
1296 module: "functions",
1299 name: "mut_from_ref",
1300 group: "correctness",
1301 desc: "fns that create mutable refs from immutable ref args",
1308 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1313 name: "mut_range_bound",
1314 group: "complexity",
1315 desc: "for loop over a range where one of the bounds is a mutable variable",
1320 name: "mutable_key_type",
1321 group: "correctness",
1322 desc: "Check for mutable `Map`/`Set` key type",
1327 name: "mutex_atomic",
1329 desc: "using a mutex where an atomic value could be used instead",
1331 module: "mutex_atomic",
1334 name: "mutex_integer",
1336 desc: "using a mutex for an integer type",
1338 module: "mutex_atomic",
1341 name: "naive_bytecount",
1343 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1345 module: "bytecount",
1348 name: "needless_bool",
1349 group: "complexity",
1350 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1352 module: "needless_bool",
1355 name: "needless_borrow",
1357 desc: "taking a reference that is going to be automatically dereferenced",
1359 module: "needless_borrow",
1362 name: "needless_borrowed_reference",
1363 group: "complexity",
1364 desc: "taking a needless borrowed reference",
1366 module: "needless_borrowed_ref",
1369 name: "needless_collect",
1371 desc: "collecting an iterator when collect is not needed",
1376 name: "needless_continue",
1378 desc: "`continue` statements that can be replaced by a rearrangement of code",
1380 module: "needless_continue",
1383 name: "needless_doctest_main",
1385 desc: "presence of `fn main() {` in code examples",
1390 name: "needless_lifetimes",
1391 group: "complexity",
1392 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1394 module: "lifetimes",
1397 name: "needless_pass_by_value",
1399 desc: "functions taking arguments by value, but not consuming them in its body",
1401 module: "needless_pass_by_value",
1404 name: "needless_range_loop",
1406 desc: "for-looping over a range of indices where an iterator over items would do",
1411 name: "needless_return",
1413 desc: "using a return statement like `return expr;` where an expression would suffice",
1418 name: "needless_update",
1419 group: "complexity",
1420 desc: "using `Foo { ..base }` when there are no missing fields",
1422 module: "needless_update",
1425 name: "neg_cmp_op_on_partial_ord",
1426 group: "complexity",
1427 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1429 module: "neg_cmp_op_on_partial_ord",
1432 name: "neg_multiply",
1434 desc: "multiplying integers with `-1`",
1436 module: "neg_multiply",
1440 group: "correctness",
1441 desc: "any loop that will always `break` or `return`",
1446 name: "new_ret_no_self",
1448 desc: "not returning `Self` in a `new` method",
1453 name: "new_without_default",
1455 desc: "`fn new() -> Self` method without `Default` implementation",
1457 module: "new_without_default",
1461 group: "complexity",
1462 desc: "statements with no effect",
1464 module: "no_effect",
1467 name: "non_ascii_literal",
1469 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1474 name: "nonminimal_bool",
1475 group: "complexity",
1476 desc: "boolean expressions that can be written more concisely",
1481 name: "nonsensical_open_options",
1482 group: "correctness",
1483 desc: "nonsensical combination of options for opening a file",
1485 module: "open_options",
1488 name: "not_unsafe_ptr_arg_deref",
1489 group: "correctness",
1490 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1492 module: "functions",
1497 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1504 desc: "taking a reference to satisfy the type constraints on `==`",
1509 name: "option_and_then_some",
1510 group: "complexity",
1511 desc: "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`",
1516 name: "option_as_ref_deref",
1517 group: "complexity",
1518 desc: "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`",
1523 name: "option_env_unwrap",
1524 group: "correctness",
1525 desc: "using `option_env!(...).unwrap()` to get environment variable",
1527 module: "option_env_unwrap",
1530 name: "option_expect_used",
1531 group: "restriction",
1532 desc: "using `Option.expect()`, which might be better handled",
1537 name: "option_map_or_none",
1539 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1544 name: "option_map_unit_fn",
1545 group: "complexity",
1546 desc: "using `option.map(f)`, where `f` is a function or closure that returns `()`",
1548 module: "map_unit_fn",
1551 name: "option_map_unwrap_or",
1553 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1558 name: "option_map_unwrap_or_else",
1560 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1565 name: "option_option",
1566 group: "complexity",
1567 desc: "usage of `Option<Option<T>>`",
1572 name: "option_unwrap_used",
1573 group: "restriction",
1574 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1579 name: "or_fun_call",
1581 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1586 name: "out_of_bounds_indexing",
1587 group: "correctness",
1588 desc: "out of bounds constant indexing",
1590 module: "indexing_slicing",
1593 name: "overflow_check_conditional",
1594 group: "complexity",
1595 desc: "overflow checks inspired by C which are likely to panic",
1597 module: "overflow_check_conditional",
1601 group: "restriction",
1602 desc: "usage of the `panic!` macro",
1604 module: "panic_unimplemented",
1607 name: "panic_params",
1609 desc: "missing parameters in `panic!` calls",
1611 module: "panic_unimplemented",
1614 name: "panicking_unwrap",
1615 group: "correctness",
1616 desc: "checks for calls of `unwrap[_err]()` that will always fail",
1621 name: "partialeq_ne_impl",
1622 group: "complexity",
1623 desc: "re-implementing `PartialEq::ne`",
1625 module: "partialeq_ne_impl",
1628 name: "path_buf_push_overwrite",
1630 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1632 module: "path_buf_push_overwrite",
1635 name: "possible_missing_comma",
1636 group: "correctness",
1637 desc: "possible missing comma in array",
1639 module: "formatting",
1643 group: "complexity",
1644 desc: "operations where precedence may be unclear",
1646 module: "precedence",
1649 name: "print_literal",
1651 desc: "printing a literal with a format string",
1656 name: "print_stdout",
1657 group: "restriction",
1658 desc: "printing on stdout",
1663 name: "print_with_newline",
1665 desc: "using `print!()` with a format string that ends in a single newline",
1670 name: "println_empty_string",
1672 desc: "using `println!(\"\")` with an empty string",
1679 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1684 name: "ptr_offset_with_cast",
1685 group: "complexity",
1686 desc: "unneeded pointer offset cast",
1688 module: "ptr_offset_with_cast",
1691 name: "pub_enum_variant_names",
1693 desc: "enums where all variants share a prefix/postfix",
1695 module: "enum_variants",
1698 name: "question_mark",
1700 desc: "checks for expressions that could be replaced by the question mark operator",
1702 module: "question_mark",
1705 name: "range_minus_one",
1706 group: "complexity",
1707 desc: "`x..=(y-1)` reads better as `x..y`",
1712 name: "range_plus_one",
1714 desc: "`x..(y+1)` reads better as `x..=y`",
1719 name: "range_zip_with_len",
1720 group: "complexity",
1721 desc: "zipping iterator with a range when `enumerate()` would do",
1726 name: "redundant_clone",
1728 desc: "`clone()` of an owned value that is going to be dropped immediately",
1730 module: "redundant_clone",
1733 name: "redundant_closure",
1735 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1737 module: "eta_reduction",
1740 name: "redundant_closure_call",
1741 group: "complexity",
1742 desc: "throwaway closures called in the expression they are defined",
1744 module: "misc_early",
1747 name: "redundant_closure_for_method_calls",
1749 desc: "redundant closures for method calls",
1751 module: "eta_reduction",
1754 name: "redundant_field_names",
1756 desc: "checks for fields in struct literals where shorthands could be used",
1758 module: "redundant_field_names",
1761 name: "redundant_pattern",
1763 desc: "using `name @ _` in a pattern",
1765 module: "misc_early",
1768 name: "redundant_pattern_matching",
1770 desc: "use the proper utility function avoiding an `if let`",
1772 module: "redundant_pattern_matching",
1775 name: "redundant_pub_crate",
1777 desc: "Using `pub(crate)` visibility on items that are not crate visible due to the visibility of the module that contains them.",
1779 module: "redundant_pub_crate",
1782 name: "redundant_static_lifetimes",
1784 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1786 module: "redundant_static_lifetimes",
1789 name: "ref_in_deref",
1790 group: "complexity",
1791 desc: "Use of reference in auto dereference expression.",
1793 module: "reference",
1796 name: "regex_macro",
1798 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1803 name: "rest_pat_in_fully_bound_structs",
1804 group: "restriction",
1805 desc: "a match on a struct that binds all fields but still uses the wildcard pattern",
1810 name: "result_expect_used",
1811 group: "restriction",
1812 desc: "using `Result.expect()`, which might be better handled",
1817 name: "result_map_unit_fn",
1818 group: "complexity",
1819 desc: "using `result.map(f)`, where `f` is a function or closure that returns `()`",
1821 module: "map_unit_fn",
1824 name: "result_map_unwrap_or_else",
1826 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.map_or_else(g, f)`",
1831 name: "result_unwrap_used",
1832 group: "restriction",
1833 desc: "using `Result.unwrap()`, which might be better handled",
1838 name: "reverse_range_loop",
1839 group: "correctness",
1840 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1845 name: "same_functions_in_if_condition",
1847 desc: "consecutive `if`s with the same function call",
1852 name: "search_is_some",
1853 group: "complexity",
1854 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1859 name: "serde_api_misuse",
1860 group: "correctness",
1861 desc: "various things that will negatively affect your serde experience",
1863 module: "serde_api",
1866 name: "shadow_reuse",
1867 group: "restriction",
1868 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1873 name: "shadow_same",
1874 group: "restriction",
1875 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1880 name: "shadow_unrelated",
1882 desc: "rebinding a name without even using the original value",
1887 name: "short_circuit_statement",
1888 group: "complexity",
1889 desc: "using a short circuit boolean condition as a statement",
1894 name: "should_implement_trait",
1896 desc: "defining a method that should be implementing a std trait",
1901 name: "similar_names",
1903 desc: "similarly named items and bindings",
1905 module: "non_expressive_names",
1908 name: "single_char_pattern",
1910 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1915 name: "single_component_path_imports",
1917 desc: "imports with single component path are redundant",
1919 module: "single_component_path_imports",
1922 name: "single_match",
1924 desc: "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1929 name: "single_match_else",
1931 desc: "a `match` statement with two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1936 name: "skip_while_next",
1937 group: "complexity",
1938 desc: "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`",
1943 name: "slow_vector_initialization",
1945 desc: "slow vector initialization",
1947 module: "slow_vector_initialization",
1951 group: "restriction",
1952 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1957 name: "string_add_assign",
1959 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1964 name: "string_extend_chars",
1966 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1971 name: "string_lit_as_bytes",
1973 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1978 name: "struct_excessive_bools",
1980 desc: "using too many bools in a struct",
1982 module: "excessive_bools",
1985 name: "suboptimal_flops",
1987 desc: "usage of sub-optimal floating point operations",
1989 module: "floating_point_arithmetic",
1992 name: "suspicious_arithmetic_impl",
1993 group: "correctness",
1994 desc: "suspicious use of operators in impl of arithmetic trait",
1996 module: "suspicious_trait_impl",
1999 name: "suspicious_assignment_formatting",
2001 desc: "suspicious formatting of `*=`, `-=` or `!=`",
2003 module: "formatting",
2006 name: "suspicious_else_formatting",
2008 desc: "suspicious formatting of `else`",
2010 module: "formatting",
2013 name: "suspicious_map",
2014 group: "complexity",
2015 desc: "suspicious usage of map",
2020 name: "suspicious_op_assign_impl",
2021 group: "correctness",
2022 desc: "suspicious use of operators in impl of OpAssign trait",
2024 module: "suspicious_trait_impl",
2027 name: "suspicious_unary_op_formatting",
2029 desc: "suspicious formatting of unary `-` or `!` on the RHS of a BinOp",
2031 module: "formatting",
2034 name: "tabs_in_doc_comments",
2036 desc: "using tabs in doc comments is not recommended",
2038 module: "tabs_in_doc_comments",
2041 name: "temporary_assignment",
2042 group: "complexity",
2043 desc: "assignments to temporaries",
2045 module: "temporary_assignment",
2048 name: "temporary_cstring_as_ptr",
2049 group: "correctness",
2050 desc: "getting the inner pointer of a temporary `CString`",
2055 name: "to_digit_is_some",
2057 desc: "`char.is_digit()` is clearer",
2059 module: "to_digit_is_some",
2063 group: "restriction",
2064 desc: "`todo!` should not be present in production code",
2066 module: "panic_unimplemented",
2069 name: "too_many_arguments",
2070 group: "complexity",
2071 desc: "functions with too many arguments",
2073 module: "functions",
2076 name: "too_many_lines",
2078 desc: "functions with too many lines",
2080 module: "functions",
2083 name: "toplevel_ref_arg",
2085 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
2090 name: "transmute_bytes_to_str",
2091 group: "complexity",
2092 desc: "transmutes from a `&[u8]` to a `&str`",
2094 module: "transmute",
2097 name: "transmute_float_to_int",
2098 group: "complexity",
2099 desc: "transmutes from a float to an integer",
2101 module: "transmute",
2104 name: "transmute_int_to_bool",
2105 group: "complexity",
2106 desc: "transmutes from an integer to a `bool`",
2108 module: "transmute",
2111 name: "transmute_int_to_char",
2112 group: "complexity",
2113 desc: "transmutes from an integer to a `char`",
2115 module: "transmute",
2118 name: "transmute_int_to_float",
2119 group: "complexity",
2120 desc: "transmutes from an integer to a float",
2122 module: "transmute",
2125 name: "transmute_ptr_to_ptr",
2126 group: "complexity",
2127 desc: "transmutes from a pointer to a pointer / a reference to a reference",
2129 module: "transmute",
2132 name: "transmute_ptr_to_ref",
2133 group: "complexity",
2134 desc: "transmutes from a pointer to a reference type",
2136 module: "transmute",
2139 name: "transmuting_null",
2140 group: "correctness",
2141 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
2143 module: "transmuting_null",
2146 name: "trivial_regex",
2148 desc: "trivial regular expressions",
2153 name: "trivially_copy_pass_by_ref",
2155 desc: "functions taking small copyable arguments by reference",
2157 module: "trivially_copy_pass_by_ref",
2162 desc: "return errors explicitly rather than hiding them behind a `?`",
2167 name: "type_complexity",
2168 group: "complexity",
2169 desc: "usage of very complex types that might be better factored into `type` definitions",
2174 name: "type_repetition_in_bounds",
2176 desc: "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`",
2178 module: "trait_bounds",
2181 name: "unicode_not_nfc",
2183 desc: "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
2188 name: "unimplemented",
2189 group: "restriction",
2190 desc: "`unimplemented!` should not be present in production code",
2192 module: "panic_unimplemented",
2195 name: "uninit_assumed_init",
2196 group: "correctness",
2197 desc: "`MaybeUninit::uninit().assume_init()`",
2203 group: "complexity",
2204 desc: "passing unit to a function",
2210 group: "correctness",
2211 desc: "comparing unit values",
2216 name: "unknown_clippy_lints",
2218 desc: "unknown_lints for scoped Clippy lints",
2223 name: "unnecessary_cast",
2224 group: "complexity",
2225 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
2230 name: "unnecessary_filter_map",
2231 group: "complexity",
2232 desc: "using `filter_map` when a more succinct alternative exists",
2237 name: "unnecessary_fold",
2239 desc: "using `fold` when a more succinct alternative exists",
2244 name: "unnecessary_mut_passed",
2246 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
2248 module: "mut_reference",
2251 name: "unnecessary_operation",
2252 group: "complexity",
2253 desc: "outer expressions with no effect",
2255 module: "no_effect",
2258 name: "unnecessary_unwrap",
2259 group: "complexity",
2260 desc: "checks for calls of `unwrap[_err]()` that cannot fail",
2265 name: "unneeded_field_pattern",
2266 group: "restriction",
2267 desc: "struct fields bound to a wildcard instead of using `..`",
2269 module: "misc_early",
2272 name: "unneeded_wildcard_pattern",
2273 group: "complexity",
2274 desc: "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)",
2276 module: "misc_early",
2279 name: "unreachable",
2280 group: "restriction",
2281 desc: "`unreachable!` should not be present in production code",
2283 module: "panic_unimplemented",
2286 name: "unreadable_literal",
2288 desc: "long integer literal without underscores",
2290 module: "literal_representation",
2293 name: "unsafe_removed_from_name",
2295 desc: "`unsafe` removed from API names on import",
2297 module: "unsafe_removed_from_name",
2300 name: "unseparated_literal_suffix",
2302 desc: "literals whose suffix is not separated by an underscore",
2304 module: "misc_early",
2307 name: "unsound_collection_transmute",
2308 group: "correctness",
2309 desc: "transmute between collections of layout-incompatible types",
2311 module: "transmute",
2314 name: "unused_io_amount",
2315 group: "correctness",
2316 desc: "unused written/read amount",
2318 module: "unused_io_amount",
2321 name: "unused_self",
2323 desc: "methods that contain a `self` argument but don\'t use it",
2325 module: "unused_self",
2328 name: "unused_unit",
2330 desc: "needless unit expression",
2336 group: "restriction",
2337 desc: "use of `Debug`-based formatting",
2344 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
2349 name: "used_underscore_binding",
2351 desc: "using a binding which is prefixed with an underscore",
2356 name: "useless_asref",
2357 group: "complexity",
2358 desc: "using `as_ref` where the types before and after the call are the same",
2363 name: "useless_attribute",
2364 group: "correctness",
2365 desc: "use of lint attributes on `extern crate` items",
2370 name: "useless_format",
2371 group: "complexity",
2372 desc: "useless use of `format!`",
2377 name: "useless_let_if_seq",
2379 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2381 module: "let_if_seq",
2384 name: "useless_transmute",
2386 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2388 module: "transmute",
2391 name: "useless_vec",
2393 desc: "useless `vec!`",
2399 group: "complexity",
2400 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2405 name: "verbose_bit_mask",
2407 desc: "expressions where a bit mask is less readable than the corresponding method call",
2412 name: "verbose_file_reads",
2413 group: "restriction",
2414 desc: "use of `File::read_to_end` or `File::read_to_string`",
2416 module: "verbose_file_reads",
2419 name: "vtable_address_comparisons",
2420 group: "correctness",
2421 desc: "comparison with an address of a trait vtable",
2423 module: "unnamed_address",
2426 name: "while_immutable_condition",
2427 group: "correctness",
2428 desc: "variables used within while expression are not mutated in the body",
2433 name: "while_let_loop",
2434 group: "complexity",
2435 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2440 name: "while_let_on_iterator",
2442 desc: "using a while-let loop instead of a for loop on an iterator",
2447 name: "wildcard_dependencies",
2449 desc: "wildcard dependencies being used",
2451 module: "wildcard_dependencies",
2454 name: "wildcard_enum_match_arm",
2455 group: "restriction",
2456 desc: "a wildcard enum match arm using `_`",
2461 name: "wildcard_imports",
2463 desc: "lint `use _::*` statements",
2465 module: "wildcard_imports",
2468 name: "wildcard_in_or_patterns",
2469 group: "complexity",
2470 desc: "a wildcard pattern used with others patterns in same match arm",
2475 name: "write_literal",
2477 desc: "writing a literal with a format string",
2482 name: "write_with_newline",
2484 desc: "using `write!()` with a format string that ends in a single newline",
2489 name: "writeln_empty_string",
2491 desc: "using `writeln!(buf, \"\")` with an empty string",
2496 name: "wrong_pub_self_convention",
2497 group: "restriction",
2498 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2503 name: "wrong_self_convention",
2505 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2510 name: "wrong_transmute",
2511 group: "correctness",
2512 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2514 module: "transmute",
2517 name: "zero_divided_by_zero",
2518 group: "complexity",
2519 desc: "usage of `0.0 / 0.0` to obtain NaN instead of `std::f32::NAN` or `std::f64::NAN`",
2521 module: "zero_div_zero",
2524 name: "zero_prefixed_literal",
2525 group: "complexity",
2526 desc: "integer literals starting with `0`",
2528 module: "misc_early",
2533 desc: "using `0 as *{const, mut} T`",
2538 name: "zero_width_space",
2539 group: "correctness",
2540 desc: "using a zero-width space in a string literal, which is confusing",
2546 group: "correctness",
2547 desc: "Check for offset calculations on raw pointers to zero-sized types",
2552 // end lint list, do not remove this comment, it’s used in `update_lints`