1 //! This file is managed by util/dev update_lints. Do not edit.
5 pub use lint::LINT_LEVELS;
7 pub const ALL_LINTS: [Lint; 304] = [
9 name: "absurd_extreme_comparisons",
11 desc: "a comparison with a maximum or minimum value that is always true or false",
16 name: "almost_swapped",
18 desc: "`foo = bar; bar = foo` sequence",
23 name: "approx_constant",
25 desc: "the approximate of a known float constant (in `std::fXX::consts`)",
27 module: "approx_const",
30 name: "assertions_on_constants",
32 desc: "`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`",
34 module: "assertions_on_constants",
37 name: "assign_op_pattern",
39 desc: "assigning the result of an operation on a variable to that same variable",
46 desc: "expressions of the form `_ & mask == select` that will only ever return `true` or `false`",
51 name: "blacklisted_name",
53 desc: "usage of a blacklisted/placeholder name",
55 module: "blacklisted_name",
58 name: "block_in_if_condition_expr",
60 desc: "braces that can be eliminated in conditions, e.g., `if { true } ...`",
62 module: "block_in_if_condition",
65 name: "block_in_if_condition_stmt",
67 desc: "complex blocks in conditions, e.g., `if { let x = true; x } ...`",
69 module: "block_in_if_condition",
72 name: "bool_comparison",
74 desc: "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`",
76 module: "needless_bool",
79 name: "borrow_interior_mutable_const",
81 desc: "referencing const with interior mutability",
83 module: "non_copy_const",
88 desc: "a borrow of a boxed type",
95 desc: "usage of `Box<Vec<T>>`, vector elements are already on the heap",
102 desc: "using `Box<T>` where unnecessary",
107 name: "builtin_type_shadow",
109 desc: "shadowing a builtin type",
111 module: "misc_early",
114 name: "cargo_common_metadata",
116 desc: "common metadata is defined in `Cargo.toml`",
118 module: "cargo_common_metadata",
121 name: "cast_lossless",
123 desc: "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`",
128 name: "cast_possible_truncation",
130 desc: "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`",
135 name: "cast_possible_wrap",
137 desc: "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`",
142 name: "cast_precision_loss",
144 desc: "casts that cause loss of precision, e.g., `x as f32` where `x: u64`",
149 name: "cast_ptr_alignment",
150 group: "correctness",
151 desc: "cast from a pointer to a more-strictly-aligned pointer",
156 name: "cast_ref_to_mut",
157 group: "correctness",
158 desc: "a cast of reference to a mutable pointer",
163 name: "cast_sign_loss",
165 desc: "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`",
170 name: "char_lit_as_u8",
172 desc: "casting a character literal to u8",
177 name: "chars_last_cmp",
179 desc: "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char",
184 name: "chars_next_cmp",
186 desc: "using `.chars().next()` to check if a string starts with a char",
191 name: "checked_conversions",
193 desc: "`try_from` could replace manual bounds checking when casting",
195 module: "checked_conversions",
198 name: "clone_double_ref",
199 group: "correctness",
200 desc: "using `clone` on `&&T`",
205 name: "clone_on_copy",
207 desc: "using `clone` on a `Copy` type",
212 name: "clone_on_ref_ptr",
213 group: "restriction",
214 desc: "using \'clone\' on a ref-counted pointer",
220 group: "correctness",
221 desc: "comparisons to NAN, which will always return false, probably not intended",
228 desc: "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead.",
235 desc: "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`",
240 name: "cognitive_complexity",
242 desc: "functions that should be split up into multiple functions",
244 module: "cognitive_complexity",
247 name: "collapsible_if",
249 desc: "`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)",
251 module: "collapsible_if",
254 name: "const_static_lifetime",
256 desc: "Using explicit `\'static` lifetime for constants when elision rules would allow omitting them.",
258 module: "const_static_lifetime",
261 name: "copy_iterator",
263 desc: "implementing `Iterator` on a `Copy` type",
265 module: "copy_iterator",
268 name: "crosspointer_transmute",
270 desc: "transmutes that have to or from types that are a pointer to the other",
276 group: "restriction",
277 desc: "`dbg!` macro is intended as a debugging tool",
282 name: "decimal_literal_representation",
283 group: "restriction",
284 desc: "using decimal representation when hexadecimal would be better",
286 module: "literal_representation",
289 name: "declare_interior_mutable_const",
290 group: "correctness",
291 desc: "declaring const with interior mutability",
293 module: "non_copy_const",
296 name: "default_trait_access",
298 desc: "checks for literal calls to Default::default()",
300 module: "default_trait_access",
303 name: "deprecated_cfg_attr",
305 desc: "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`",
310 name: "deprecated_semver",
311 group: "correctness",
312 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
317 name: "deref_addrof",
319 desc: "use of `*&` or `*&mut` in an expression",
324 name: "derive_hash_xor_eq",
325 group: "correctness",
326 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
331 name: "diverging_sub_expression",
333 desc: "whether an expression contains a diverging sub expression",
335 module: "eval_order_dependence",
338 name: "doc_markdown",
340 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
345 name: "double_comparisons",
347 desc: "unnecessary double comparisons that can be simplified",
349 module: "double_comparison",
354 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
356 module: "misc_early",
359 name: "double_parens",
361 desc: "Warn on unnecessary double parentheses",
363 module: "double_parens",
367 group: "correctness",
368 desc: "Bounds of the form `T: Drop` are useless",
370 module: "drop_bounds",
374 group: "correctness",
375 desc: "calls to `std::mem::drop` with a value that implements Copy",
377 module: "drop_forget_ref",
381 group: "correctness",
382 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
384 module: "drop_forget_ref",
387 name: "duplicate_underscore_argument",
389 desc: "function arguments having names which only differ by an underscore",
391 module: "misc_early",
394 name: "duration_subsec",
396 desc: "checks for calculation of subsecond microseconds or milliseconds",
398 module: "duration_subsec",
401 name: "else_if_without_else",
402 group: "restriction",
403 desc: "if expression with an `else if`, but without a final `else` branch",
405 module: "else_if_without_else",
410 desc: "enum with no variants",
412 module: "empty_enum",
415 name: "empty_line_after_outer_attr",
417 desc: "empty line after outer attribute",
424 desc: "empty `loop {}`, which should block or sleep",
429 name: "enum_clike_unportable_variant",
430 group: "correctness",
431 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
433 module: "enum_clike",
436 name: "enum_glob_use",
438 desc: "use items that import all variants of an enum",
440 module: "enum_glob_use",
443 name: "enum_variant_names",
445 desc: "enums where all variants share a prefix/postfix",
447 module: "enum_variants",
451 group: "correctness",
452 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
458 group: "correctness",
459 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
461 module: "erasing_op",
464 name: "eval_order_dependence",
466 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
468 module: "eval_order_dependence",
471 name: "excessive_precision",
473 desc: "excessive precision for float literal",
475 module: "excessive_precision",
478 name: "expect_fun_call",
480 desc: "using any `expect` method with a function call",
485 name: "expl_impl_clone_on_copy",
487 desc: "implementing `Clone` explicitly on `Copy` types",
492 name: "explicit_counter_loop",
494 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
499 name: "explicit_into_iter_loop",
501 desc: "for-looping over `_.into_iter()` when `_` would do",
506 name: "explicit_iter_loop",
508 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
513 name: "explicit_write",
515 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
517 module: "explicit_write",
520 name: "extra_unused_lifetimes",
522 desc: "unused lifetimes in function definitions",
527 name: "fallible_impl_from",
529 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
531 module: "fallible_impl_from",
536 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
541 name: "filter_map_next",
543 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
550 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
557 desc: "using a combination of `find` and `map` can usually be written as a single method call",
562 name: "float_arithmetic",
563 group: "restriction",
564 desc: "any floating-point arithmetic statement",
566 module: "arithmetic",
570 group: "correctness",
571 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
576 name: "float_cmp_const",
577 group: "restriction",
578 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
583 name: "fn_to_numeric_cast",
585 desc: "casting a function pointer to a numeric type other than usize",
590 name: "fn_to_numeric_cast_with_truncation",
592 desc: "casting a function pointer to a numeric type not wide enough to store the address",
599 desc: "looping on a map using `iter` when `keys` or `values` would do",
604 name: "for_loop_over_option",
605 group: "correctness",
606 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
611 name: "for_loop_over_result",
612 group: "correctness",
613 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
619 group: "correctness",
620 desc: "calls to `std::mem::forget` with a value that implements Copy",
622 module: "drop_forget_ref",
626 group: "correctness",
627 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
629 module: "drop_forget_ref",
632 name: "get_last_with_len",
634 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
636 module: "get_last_with_len",
640 group: "restriction",
641 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
646 name: "identity_conversion",
648 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
650 module: "identity_conversion",
655 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
657 module: "identity_op",
660 name: "if_let_some_result",
662 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
669 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
671 module: "if_not_else",
674 name: "if_same_then_else",
675 group: "correctness",
676 desc: "if with the same *then* and *else* blocks",
681 name: "ifs_same_cond",
682 group: "correctness",
683 desc: "consecutive `ifs` with the same condition",
688 name: "implicit_hasher",
690 desc: "missing generalization over different hashers",
695 name: "implicit_return",
696 group: "restriction",
697 desc: "use a return statement like `return expr` instead of an expression",
699 module: "implicit_return",
702 name: "inconsistent_digit_grouping",
704 desc: "integer literals with digits grouped inconsistently",
706 module: "literal_representation",
709 name: "indexing_slicing",
710 group: "restriction",
711 desc: "indexing/slicing usage",
713 module: "indexing_slicing",
716 name: "ineffective_bit_mask",
717 group: "correctness",
718 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
723 name: "infallible_destructuring_match",
725 desc: "a match statement with a single infallible arm instead of a `let`",
727 module: "infallible_destructuring_match",
730 name: "infinite_iter",
731 group: "correctness",
732 desc: "infinite iteration",
734 module: "infinite_iter",
737 name: "inline_always",
739 desc: "use of `#[inline(always)]`",
744 name: "inline_fn_without_body",
745 group: "correctness",
746 desc: "use of `#[inline]` on trait methods without bodies",
748 module: "inline_fn_without_body",
751 name: "int_plus_one",
753 desc: "instead of using x >= y + 1, use x > y",
755 module: "int_plus_one",
758 name: "integer_arithmetic",
759 group: "restriction",
760 desc: "any integer arithmetic statement",
762 module: "arithmetic",
765 name: "into_iter_on_array",
766 group: "correctness",
767 desc: "using `.into_iter()` on an array",
772 name: "into_iter_on_ref",
774 desc: "using `.into_iter()` on a reference",
780 group: "correctness",
781 desc: "creation of invalid reference",
783 module: "invalid_ref",
786 name: "invalid_regex",
787 group: "correctness",
788 desc: "invalid regular expressions",
793 name: "invalid_upcast_comparisons",
795 desc: "a comparison involving an upcast which is always true or false",
800 name: "items_after_statements",
802 desc: "blocks where an item comes after a statement",
804 module: "items_after_statements",
807 name: "iter_cloned_collect",
809 desc: "using `.cloned().collect()` on slice to create a `Vec`",
814 name: "iter_next_loop",
815 group: "correctness",
816 desc: "for-looping over `_.next()` which is probably not intended",
823 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
828 name: "iter_skip_next",
830 desc: "using `.skip(x).next()` on an iterator",
835 name: "iterator_step_by_zero",
836 group: "correctness",
837 desc: "using `Iterator::step_by(0)`, which produces an infinite iterator",
842 name: "just_underscores_and_digits",
844 desc: "unclear name",
846 module: "non_expressive_names",
849 name: "large_digit_groups",
851 desc: "grouping digits into groups that are too large",
853 module: "literal_representation",
856 name: "large_enum_variant",
858 desc: "large size difference between variants on an enum",
860 module: "large_enum_variant",
863 name: "len_without_is_empty",
865 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
872 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
877 name: "let_and_return",
879 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
884 name: "let_unit_value",
886 desc: "creating a let binding to a value of unit type, which usually can\'t be used afterwards",
893 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a VecDeque",
899 group: "correctness",
900 desc: "boolean expressions that contain terminals which can be eliminated",
905 name: "manual_memcpy",
907 desc: "manually copying items between slices",
914 desc: "manual swap of two variables",
919 name: "many_single_char_names",
921 desc: "too many single character bindings",
923 module: "non_expressive_names",
928 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
935 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
942 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
947 name: "match_as_ref",
949 desc: "a match on an Option value instead of using `as_ref()` or `as_mut`",
956 desc: "a match on a boolean expression instead of an `if..else` block",
961 name: "match_overlapping_arm",
963 desc: "a match with overlapping arms",
968 name: "match_ref_pats",
970 desc: "a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
975 name: "match_same_arms",
977 desc: "`match` with identical arm bodies",
982 name: "match_wild_err_arm",
984 desc: "a match with `Err(_)` arm and take drastic actions",
989 name: "maybe_infinite_iter",
991 desc: "possible infinite iteration",
993 module: "infinite_iter",
996 name: "mem_discriminant_non_enum",
997 group: "correctness",
998 desc: "calling mem::descriminant on non-enum type",
1000 module: "mem_discriminant",
1004 group: "restriction",
1005 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1007 module: "mem_forget",
1010 name: "mem_replace_option_with_none",
1012 desc: "replacing an `Option` with `None` instead of `take()`",
1014 module: "mem_replace",
1018 group: "correctness",
1019 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1024 name: "misrefactored_assign_op",
1025 group: "complexity",
1026 desc: "having a variable on both sides of an assign op",
1028 module: "assign_ops",
1031 name: "missing_const_for_fn",
1033 desc: "Lint functions definitions that could be made `const fn`",
1035 module: "missing_const_for_fn",
1038 name: "missing_docs_in_private_items",
1039 group: "restriction",
1040 desc: "detects missing documentation for public and private members",
1042 module: "missing_doc",
1045 name: "missing_inline_in_public_items",
1046 group: "restriction",
1047 desc: "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)",
1049 module: "missing_inline",
1052 name: "mistyped_literal_suffixes",
1053 group: "correctness",
1054 desc: "mistyped literal suffix",
1056 module: "literal_representation",
1059 name: "mixed_case_hex_literals",
1061 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1063 module: "misc_early",
1066 name: "module_inception",
1068 desc: "modules that have the same name as their parent module",
1070 module: "enum_variants",
1073 name: "module_name_repetitions",
1075 desc: "type names prefixed/postfixed with their containing module\'s name",
1077 module: "enum_variants",
1081 group: "correctness",
1082 desc: "taking a number modulo 1, which always returns 0",
1087 name: "multiple_crate_versions",
1089 desc: "multiple versions of the same crate being used",
1091 module: "multiple_crate_versions",
1094 name: "multiple_inherent_impl",
1095 group: "restriction",
1096 desc: "Multiple inherent impl that could be grouped",
1098 module: "inherent_impl",
1101 name: "mut_from_ref",
1102 group: "correctness",
1103 desc: "fns that create mutable refs from immutable ref args",
1110 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1115 name: "mut_range_bound",
1116 group: "complexity",
1117 desc: "for loop over a range where one of the bounds is a mutable variable",
1122 name: "mutex_atomic",
1124 desc: "using a mutex where an atomic value could be used instead",
1126 module: "mutex_atomic",
1129 name: "mutex_integer",
1131 desc: "using a mutex for an integer type",
1133 module: "mutex_atomic",
1136 name: "naive_bytecount",
1138 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1140 module: "bytecount",
1143 name: "needless_bool",
1144 group: "complexity",
1145 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1147 module: "needless_bool",
1150 name: "needless_borrow",
1152 desc: "taking a reference that is going to be automatically dereferenced",
1154 module: "needless_borrow",
1157 name: "needless_borrowed_reference",
1158 group: "complexity",
1159 desc: "taking a needless borrowed reference",
1161 module: "needless_borrowed_ref",
1164 name: "needless_collect",
1166 desc: "collecting an iterator when collect is not needed",
1171 name: "needless_continue",
1173 desc: "`continue` statements that can be replaced by a rearrangement of code",
1175 module: "needless_continue",
1178 name: "needless_lifetimes",
1179 group: "complexity",
1180 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1182 module: "lifetimes",
1185 name: "needless_pass_by_value",
1187 desc: "functions taking arguments by value, but not consuming them in its body",
1189 module: "needless_pass_by_value",
1192 name: "needless_range_loop",
1194 desc: "for-looping over a range of indices where an iterator over items would do",
1199 name: "needless_return",
1201 desc: "using a return statement like `return expr;` where an expression would suffice",
1206 name: "needless_update",
1207 group: "complexity",
1208 desc: "using `Foo { ..base }` when there are no missing fields",
1210 module: "needless_update",
1213 name: "neg_cmp_op_on_partial_ord",
1214 group: "complexity",
1215 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1217 module: "neg_cmp_op_on_partial_ord",
1220 name: "neg_multiply",
1222 desc: "multiplying integers with -1",
1224 module: "neg_multiply",
1228 group: "correctness",
1229 desc: "any loop that will always `break` or `return`",
1234 name: "new_ret_no_self",
1236 desc: "not returning `Self` in a `new` method",
1241 name: "new_without_default",
1243 desc: "`fn new() -> Self` method without `Default` implementation",
1245 module: "new_without_default",
1249 group: "complexity",
1250 desc: "statements with no effect",
1252 module: "no_effect",
1255 name: "non_ascii_literal",
1257 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1262 name: "nonminimal_bool",
1263 group: "complexity",
1264 desc: "boolean expressions that can be written more concisely",
1269 name: "nonsensical_open_options",
1270 group: "correctness",
1271 desc: "nonsensical combination of options for opening a file",
1273 module: "open_options",
1276 name: "not_unsafe_ptr_arg_deref",
1277 group: "correctness",
1278 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1280 module: "functions",
1285 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1292 desc: "taking a reference to satisfy the type constraints on `==`",
1297 name: "option_map_or_none",
1299 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1304 name: "option_map_unit_fn",
1305 group: "complexity",
1306 desc: "using `option.map(f)`, where f is a function or closure that returns ()",
1308 module: "map_unit_fn",
1311 name: "option_map_unwrap_or",
1313 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1318 name: "option_map_unwrap_or_else",
1320 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1325 name: "option_option",
1326 group: "complexity",
1327 desc: "usage of `Option<Option<T>>`",
1332 name: "option_unwrap_used",
1333 group: "restriction",
1334 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1339 name: "or_fun_call",
1341 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1346 name: "out_of_bounds_indexing",
1347 group: "correctness",
1348 desc: "out of bounds constant indexing",
1350 module: "indexing_slicing",
1353 name: "overflow_check_conditional",
1354 group: "complexity",
1355 desc: "overflow checks inspired by C which are likely to panic",
1357 module: "overflow_check_conditional",
1360 name: "panic_params",
1362 desc: "missing parameters in `panic!` calls",
1364 module: "panic_unimplemented",
1367 name: "panicking_unwrap",
1369 desc: "checks for calls of unwrap[_err]() that will always fail",
1374 name: "partialeq_ne_impl",
1375 group: "complexity",
1376 desc: "re-implementing `PartialEq::ne`",
1378 module: "partialeq_ne_impl",
1381 name: "path_buf_push_overwrite",
1383 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1385 module: "path_buf_push_overwrite",
1388 name: "possible_missing_comma",
1389 group: "correctness",
1390 desc: "possible missing comma in array",
1392 module: "formatting",
1396 group: "complexity",
1397 desc: "operations where precedence may be unclear",
1399 module: "precedence",
1402 name: "print_literal",
1404 desc: "printing a literal with a format string",
1409 name: "print_stdout",
1410 group: "restriction",
1411 desc: "printing on stdout",
1416 name: "print_with_newline",
1418 desc: "using `print!()` with a format string that ends in a single newline",
1423 name: "println_empty_string",
1425 desc: "using `println!(\"\")` with an empty string",
1432 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1437 name: "ptr_offset_with_cast",
1438 group: "complexity",
1439 desc: "unneeded pointer offset cast",
1441 module: "ptr_offset_with_cast",
1444 name: "pub_enum_variant_names",
1446 desc: "enums where all variants share a prefix/postfix",
1448 module: "enum_variants",
1451 name: "question_mark",
1453 desc: "checks for expressions that could be replaced by the question mark operator",
1455 module: "question_mark",
1458 name: "range_minus_one",
1459 group: "complexity",
1460 desc: "`x..=(y-1)` reads better as `x..y`",
1465 name: "range_plus_one",
1466 group: "complexity",
1467 desc: "`x..(y+1)` reads better as `x..=y`",
1472 name: "range_zip_with_len",
1473 group: "complexity",
1474 desc: "zipping iterator with a range when `enumerate()` would do",
1479 name: "redundant_clone",
1481 desc: "`clone()` of an owned value that is going to be dropped immediately",
1483 module: "redundant_clone",
1486 name: "redundant_closure",
1488 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1490 module: "eta_reduction",
1493 name: "redundant_closure_call",
1494 group: "complexity",
1495 desc: "throwaway closures called in the expression they are defined",
1497 module: "misc_early",
1500 name: "redundant_closure_for_method_calls",
1502 desc: "redundant closures for method calls",
1504 module: "eta_reduction",
1507 name: "redundant_field_names",
1509 desc: "checks for fields in struct literals where shorthands could be used",
1511 module: "redundant_field_names",
1514 name: "redundant_pattern",
1516 desc: "using `name @ _` in a pattern",
1521 name: "redundant_pattern_matching",
1523 desc: "use the proper utility function avoiding an `if let`",
1525 module: "redundant_pattern_matching",
1528 name: "ref_in_deref",
1529 group: "complexity",
1530 desc: "Use of reference in auto dereference expression.",
1532 module: "reference",
1535 name: "regex_macro",
1537 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1542 name: "replace_consts",
1544 desc: "Lint usages of standard library `const`s that could be replaced by `const fn`s",
1546 module: "replace_consts",
1549 name: "result_map_unit_fn",
1550 group: "complexity",
1551 desc: "using `result.map(f)`, where f is a function or closure that returns ()",
1553 module: "map_unit_fn",
1556 name: "result_map_unwrap_or_else",
1558 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.ok().map_or_else(g, f)`",
1563 name: "result_unwrap_used",
1564 group: "restriction",
1565 desc: "using `Result.unwrap()`, which might be better handled",
1570 name: "reverse_range_loop",
1571 group: "correctness",
1572 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1577 name: "search_is_some",
1578 group: "complexity",
1579 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1584 name: "serde_api_misuse",
1585 group: "correctness",
1586 desc: "various things that will negatively affect your serde experience",
1588 module: "serde_api",
1591 name: "shadow_reuse",
1592 group: "restriction",
1593 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1598 name: "shadow_same",
1599 group: "restriction",
1600 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1605 name: "shadow_unrelated",
1607 desc: "rebinding a name without even using the original value",
1612 name: "short_circuit_statement",
1613 group: "complexity",
1614 desc: "using a short circuit boolean condition as a statement",
1619 name: "should_implement_trait",
1621 desc: "defining a method that should be implementing a std trait",
1626 name: "similar_names",
1628 desc: "similarly named items and bindings",
1630 module: "non_expressive_names",
1633 name: "single_char_pattern",
1635 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1640 name: "single_match",
1642 desc: "a match statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1647 name: "single_match_else",
1649 desc: "a match statement with a two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1654 name: "slow_vector_initialization",
1656 desc: "slow vector initialization",
1658 module: "slow_vector_initialization",
1662 group: "restriction",
1663 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1668 name: "string_add_assign",
1670 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1675 name: "string_extend_chars",
1677 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1682 name: "string_lit_as_bytes",
1684 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1689 name: "suspicious_arithmetic_impl",
1690 group: "correctness",
1691 desc: "suspicious use of operators in impl of arithmetic trait",
1693 module: "suspicious_trait_impl",
1696 name: "suspicious_assignment_formatting",
1698 desc: "suspicious formatting of `*=`, `-=` or `!=`",
1700 module: "formatting",
1703 name: "suspicious_else_formatting",
1705 desc: "suspicious formatting of `else`",
1707 module: "formatting",
1710 name: "suspicious_op_assign_impl",
1711 group: "correctness",
1712 desc: "suspicious use of operators in impl of OpAssign trait",
1714 module: "suspicious_trait_impl",
1717 name: "temporary_assignment",
1718 group: "complexity",
1719 desc: "assignments to temporaries",
1721 module: "temporary_assignment",
1724 name: "temporary_cstring_as_ptr",
1725 group: "correctness",
1726 desc: "getting the inner pointer of a temporary `CString`",
1731 name: "too_many_arguments",
1732 group: "complexity",
1733 desc: "functions with too many arguments",
1735 module: "functions",
1738 name: "too_many_lines",
1740 desc: "functions with too many lines",
1742 module: "functions",
1745 name: "toplevel_ref_arg",
1747 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
1752 name: "transmute_bytes_to_str",
1753 group: "complexity",
1754 desc: "transmutes from a `&[u8]` to a `&str`",
1756 module: "transmute",
1759 name: "transmute_int_to_bool",
1760 group: "complexity",
1761 desc: "transmutes from an integer to a `bool`",
1763 module: "transmute",
1766 name: "transmute_int_to_char",
1767 group: "complexity",
1768 desc: "transmutes from an integer to a `char`",
1770 module: "transmute",
1773 name: "transmute_int_to_float",
1774 group: "complexity",
1775 desc: "transmutes from an integer to a float",
1777 module: "transmute",
1780 name: "transmute_ptr_to_ptr",
1781 group: "complexity",
1782 desc: "transmutes from a pointer to a pointer / a reference to a reference",
1784 module: "transmute",
1787 name: "transmute_ptr_to_ref",
1788 group: "complexity",
1789 desc: "transmutes from a pointer to a reference type",
1791 module: "transmute",
1794 name: "transmuting_null",
1795 group: "correctness",
1796 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
1798 module: "transmuting_null",
1801 name: "trivial_regex",
1803 desc: "trivial regular expressions",
1808 name: "trivially_copy_pass_by_ref",
1810 desc: "functions taking small copyable arguments by reference",
1812 module: "trivially_copy_pass_by_ref",
1815 name: "type_complexity",
1816 group: "complexity",
1817 desc: "usage of very complex types that might be better factored into `type` definitions",
1822 name: "unicode_not_nfc",
1824 desc: "using a unicode literal not in NFC normal form (see [unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
1829 name: "unimplemented",
1830 group: "restriction",
1831 desc: "`unimplemented!` should not be present in production code",
1833 module: "panic_unimplemented",
1837 group: "complexity",
1838 desc: "passing unit to a function",
1844 group: "correctness",
1845 desc: "comparing unit values",
1850 name: "unknown_clippy_lints",
1852 desc: "unknown_lints for scoped Clippy lints",
1857 name: "unnecessary_cast",
1858 group: "complexity",
1859 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
1864 name: "unnecessary_filter_map",
1865 group: "complexity",
1866 desc: "using `filter_map` when a more succinct alternative exists",
1871 name: "unnecessary_fold",
1873 desc: "using `fold` when a more succinct alternative exists",
1878 name: "unnecessary_mut_passed",
1880 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
1882 module: "mut_reference",
1885 name: "unnecessary_operation",
1886 group: "complexity",
1887 desc: "outer expressions with no effect",
1889 module: "no_effect",
1892 name: "unnecessary_unwrap",
1894 desc: "checks for calls of unwrap[_err]() that cannot fail",
1899 name: "unneeded_field_pattern",
1901 desc: "struct fields bound to a wildcard instead of using `..`",
1903 module: "misc_early",
1906 name: "unreadable_literal",
1908 desc: "long integer literal without underscores",
1910 module: "literal_representation",
1913 name: "unsafe_removed_from_name",
1915 desc: "`unsafe` removed from API names on import",
1917 module: "unsafe_removed_from_name",
1920 name: "unseparated_literal_suffix",
1922 desc: "literals whose suffix is not separated by an underscore",
1924 module: "misc_early",
1927 name: "unused_collect",
1929 desc: "`collect()`ing an iterator without using the result; this is usually better written as a for loop",
1934 name: "unused_io_amount",
1935 group: "correctness",
1936 desc: "unused written/read amount",
1938 module: "unused_io_amount",
1941 name: "unused_label",
1942 group: "complexity",
1943 desc: "unused labels",
1945 module: "unused_label",
1948 name: "unused_unit",
1950 desc: "needless unit expression",
1956 group: "restriction",
1957 desc: "use of `Debug`-based formatting",
1964 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
1969 name: "used_underscore_binding",
1971 desc: "using a binding which is prefixed with an underscore",
1976 name: "useless_asref",
1977 group: "complexity",
1978 desc: "using `as_ref` where the types before and after the call are the same",
1983 name: "useless_attribute",
1984 group: "correctness",
1985 desc: "use of lint attributes on `extern crate` items",
1990 name: "useless_format",
1991 group: "complexity",
1992 desc: "useless use of `format!`",
1997 name: "useless_let_if_seq",
1999 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2001 module: "let_if_seq",
2004 name: "useless_transmute",
2005 group: "complexity",
2006 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2008 module: "transmute",
2011 name: "useless_vec",
2013 desc: "useless `vec!`",
2019 group: "complexity",
2020 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2025 name: "verbose_bit_mask",
2027 desc: "expressions where a bit mask is less readable than the corresponding method call",
2032 name: "while_immutable_condition",
2033 group: "correctness",
2034 desc: "variables used within while expression are not mutated in the body",
2039 name: "while_let_loop",
2040 group: "complexity",
2041 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2046 name: "while_let_on_iterator",
2048 desc: "using a while-let loop instead of a for loop on an iterator",
2053 name: "wildcard_dependencies",
2055 desc: "wildcard dependencies being used",
2057 module: "wildcard_dependencies",
2060 name: "wildcard_enum_match_arm",
2061 group: "restriction",
2062 desc: "a wildcard enum match arm using `_`",
2067 name: "write_literal",
2069 desc: "writing a literal with a format string",
2074 name: "write_with_newline",
2076 desc: "using `write!()` with a format string that ends in a single newline",
2081 name: "writeln_empty_string",
2083 desc: "using `writeln!(buf, \"\")` with an empty string",
2088 name: "wrong_pub_self_convention",
2089 group: "restriction",
2090 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2095 name: "wrong_self_convention",
2097 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2102 name: "wrong_transmute",
2103 group: "correctness",
2104 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2106 module: "transmute",
2109 name: "zero_divided_by_zero",
2110 group: "complexity",
2111 desc: "usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN",
2113 module: "zero_div_zero",
2116 name: "zero_prefixed_literal",
2117 group: "complexity",
2118 desc: "integer literals starting with `0`",
2120 module: "misc_early",
2125 desc: "using 0 as *{const, mut} T",
2130 name: "zero_width_space",
2131 group: "correctness",
2132 desc: "using a zero-width space in a string literal, which is confusing",