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; 306] = [
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",
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: "copy_iterator",
258 desc: "implementing `Iterator` on a `Copy` type",
260 module: "copy_iterator",
263 name: "crosspointer_transmute",
265 desc: "transmutes that have to or from types that are a pointer to the other",
271 group: "restriction",
272 desc: "`dbg!` macro is intended as a debugging tool",
277 name: "decimal_literal_representation",
278 group: "restriction",
279 desc: "using decimal representation when hexadecimal would be better",
281 module: "literal_representation",
284 name: "declare_interior_mutable_const",
285 group: "correctness",
286 desc: "declaring const with interior mutability",
288 module: "non_copy_const",
291 name: "default_trait_access",
293 desc: "checks for literal calls to Default::default()",
295 module: "default_trait_access",
298 name: "deprecated_cfg_attr",
300 desc: "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`",
305 name: "deprecated_semver",
306 group: "correctness",
307 desc: "use of `#[deprecated(since = \"x\")]` where x is not semver",
312 name: "deref_addrof",
314 desc: "use of `*&` or `*&mut` in an expression",
319 name: "derive_hash_xor_eq",
320 group: "correctness",
321 desc: "deriving `Hash` but implementing `PartialEq` explicitly",
326 name: "diverging_sub_expression",
328 desc: "whether an expression contains a diverging sub expression",
330 module: "eval_order_dependence",
333 name: "doc_markdown",
335 desc: "presence of `_`, `::` or camel-case outside backticks in documentation",
340 name: "double_comparisons",
342 desc: "unnecessary double comparisons that can be simplified",
344 module: "double_comparison",
349 desc: "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++",
351 module: "misc_early",
354 name: "double_parens",
356 desc: "Warn on unnecessary double parentheses",
358 module: "double_parens",
362 group: "correctness",
363 desc: "Bounds of the form `T: Drop` are useless",
365 module: "drop_bounds",
369 group: "correctness",
370 desc: "calls to `std::mem::drop` with a value that implements Copy",
372 module: "drop_forget_ref",
376 group: "correctness",
377 desc: "calls to `std::mem::drop` with a reference instead of an owned value",
379 module: "drop_forget_ref",
382 name: "duplicate_underscore_argument",
384 desc: "function arguments having names which only differ by an underscore",
386 module: "misc_early",
389 name: "duration_subsec",
391 desc: "checks for calculation of subsecond microseconds or milliseconds",
393 module: "duration_subsec",
396 name: "else_if_without_else",
397 group: "restriction",
398 desc: "if expression with an `else if`, but without a final `else` branch",
400 module: "else_if_without_else",
405 desc: "enum with no variants",
407 module: "empty_enum",
410 name: "empty_line_after_outer_attr",
412 desc: "empty line after outer attribute",
419 desc: "empty `loop {}`, which should block or sleep",
424 name: "enum_clike_unportable_variant",
425 group: "correctness",
426 desc: "C-like enums that are `repr(isize/usize)` and have values that don\'t fit into an `i32`",
428 module: "enum_clike",
431 name: "enum_glob_use",
433 desc: "use items that import all variants of an enum",
435 module: "enum_glob_use",
438 name: "enum_variant_names",
440 desc: "enums where all variants share a prefix/postfix",
442 module: "enum_variants",
446 group: "correctness",
447 desc: "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)",
453 group: "correctness",
454 desc: "using erasing operations, e.g., `x * 0` or `y & 0`",
456 module: "erasing_op",
459 name: "eval_order_dependence",
461 desc: "whether a variable read occurs before a write depends on sub-expression evaluation order",
463 module: "eval_order_dependence",
466 name: "excessive_precision",
468 desc: "excessive precision for float literal",
470 module: "excessive_precision",
473 name: "expect_fun_call",
475 desc: "using any `expect` method with a function call",
480 name: "expl_impl_clone_on_copy",
482 desc: "implementing `Clone` explicitly on `Copy` types",
487 name: "explicit_counter_loop",
489 desc: "for-looping with an explicit counter when `_.enumerate()` would do",
494 name: "explicit_into_iter_loop",
496 desc: "for-looping over `_.into_iter()` when `_` would do",
501 name: "explicit_iter_loop",
503 desc: "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do",
508 name: "explicit_write",
510 desc: "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work",
512 module: "explicit_write",
515 name: "extra_unused_lifetimes",
517 desc: "unused lifetimes in function definitions",
522 name: "fallible_impl_from",
524 desc: "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`",
526 module: "fallible_impl_from",
531 desc: "using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call",
536 name: "filter_map_next",
538 desc: "using combination of `filter_map` and `next` which can usually be written as a single method call",
545 desc: "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`",
552 desc: "using a combination of `find` and `map` can usually be written as a single method call",
557 name: "float_arithmetic",
558 group: "restriction",
559 desc: "any floating-point arithmetic statement",
561 module: "arithmetic",
565 group: "correctness",
566 desc: "using `==` or `!=` on float values instead of comparing difference with an epsilon",
571 name: "float_cmp_const",
572 group: "restriction",
573 desc: "using `==` or `!=` on float constants instead of comparing difference with an epsilon",
578 name: "fn_to_numeric_cast",
580 desc: "casting a function pointer to a numeric type other than usize",
585 name: "fn_to_numeric_cast_with_truncation",
587 desc: "casting a function pointer to a numeric type not wide enough to store the address",
594 desc: "looping on a map using `iter` when `keys` or `values` would do",
599 name: "for_loop_over_option",
600 group: "correctness",
601 desc: "for-looping over an `Option`, which is more clearly expressed as an `if let`",
606 name: "for_loop_over_result",
607 group: "correctness",
608 desc: "for-looping over a `Result`, which is more clearly expressed as an `if let`",
614 group: "correctness",
615 desc: "calls to `std::mem::forget` with a value that implements Copy",
617 module: "drop_forget_ref",
621 group: "correctness",
622 desc: "calls to `std::mem::forget` with a reference instead of an owned value",
624 module: "drop_forget_ref",
627 name: "get_last_with_len",
629 desc: "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler",
631 module: "get_last_with_len",
635 group: "restriction",
636 desc: "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead",
641 name: "identity_conversion",
643 desc: "using always-identical `Into`/`From`/`IntoIter` conversions",
645 module: "identity_conversion",
650 desc: "using identity operations, e.g., `x + 0` or `y / 1`",
652 module: "identity_op",
655 name: "if_let_some_result",
657 desc: "usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead",
664 desc: "`if` branches that could be swapped so no negation operation is necessary on the condition",
666 module: "if_not_else",
669 name: "if_same_then_else",
670 group: "correctness",
671 desc: "if with the same *then* and *else* blocks",
676 name: "ifs_same_cond",
677 group: "correctness",
678 desc: "consecutive `ifs` with the same condition",
683 name: "implicit_hasher",
685 desc: "missing generalization over different hashers",
690 name: "implicit_return",
691 group: "restriction",
692 desc: "use a return statement like `return expr` instead of an expression",
694 module: "implicit_return",
697 name: "inconsistent_digit_grouping",
699 desc: "integer literals with digits grouped inconsistently",
701 module: "literal_representation",
704 name: "indexing_slicing",
705 group: "restriction",
706 desc: "indexing/slicing usage",
708 module: "indexing_slicing",
711 name: "ineffective_bit_mask",
712 group: "correctness",
713 desc: "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`",
718 name: "infallible_destructuring_match",
720 desc: "a match statement with a single infallible arm instead of a `let`",
722 module: "infallible_destructuring_match",
725 name: "infinite_iter",
726 group: "correctness",
727 desc: "infinite iteration",
729 module: "infinite_iter",
732 name: "inline_always",
734 desc: "use of `#[inline(always)]`",
739 name: "inline_fn_without_body",
740 group: "correctness",
741 desc: "use of `#[inline]` on trait methods without bodies",
743 module: "inline_fn_without_body",
746 name: "int_plus_one",
748 desc: "instead of using x >= y + 1, use x > y",
750 module: "int_plus_one",
753 name: "integer_arithmetic",
754 group: "restriction",
755 desc: "any integer arithmetic statement",
757 module: "arithmetic",
760 name: "integer_division",
761 group: "restriction",
762 desc: "integer division may cause loss of precision",
764 module: "integer_division",
767 name: "into_iter_on_array",
768 group: "correctness",
769 desc: "using `.into_iter()` on an array",
774 name: "into_iter_on_ref",
776 desc: "using `.into_iter()` on a reference",
782 group: "correctness",
783 desc: "creation of invalid reference",
785 module: "invalid_ref",
788 name: "invalid_regex",
789 group: "correctness",
790 desc: "invalid regular expressions",
795 name: "invalid_upcast_comparisons",
797 desc: "a comparison involving an upcast which is always true or false",
802 name: "items_after_statements",
804 desc: "blocks where an item comes after a statement",
806 module: "items_after_statements",
809 name: "iter_cloned_collect",
811 desc: "using `.cloned().collect()` on slice to create a `Vec`",
816 name: "iter_next_loop",
817 group: "correctness",
818 desc: "for-looping over `_.next()` which is probably not intended",
825 desc: "using `.iter().nth()` on a standard library type with O(1) element access",
830 name: "iter_skip_next",
832 desc: "using `.skip(x).next()` on an iterator",
837 name: "iterator_step_by_zero",
838 group: "correctness",
839 desc: "using `Iterator::step_by(0)`, which produces an infinite iterator",
844 name: "just_underscores_and_digits",
846 desc: "unclear name",
848 module: "non_expressive_names",
851 name: "large_digit_groups",
853 desc: "grouping digits into groups that are too large",
855 module: "literal_representation",
858 name: "large_enum_variant",
860 desc: "large size difference between variants on an enum",
862 module: "large_enum_variant",
865 name: "len_without_is_empty",
867 desc: "traits or impls with a public `len` method but no corresponding `is_empty` method",
874 desc: "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead",
879 name: "let_and_return",
881 desc: "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block",
886 name: "let_unit_value",
888 desc: "creating a let binding to a value of unit type, which usually can\'t be used afterwards",
895 desc: "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a VecDeque",
901 group: "correctness",
902 desc: "boolean expressions that contain terminals which can be eliminated",
907 name: "manual_memcpy",
909 desc: "manually copying items between slices",
916 desc: "manual swap of two variables",
921 name: "many_single_char_names",
923 desc: "too many single character bindings",
925 module: "non_expressive_names",
930 desc: "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types",
937 desc: "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`",
944 desc: "using combinations of `flatten` and `map` which can usually be written as a single method call",
949 name: "match_as_ref",
951 desc: "a match on an Option value instead of using `as_ref()` or `as_mut`",
958 desc: "a match on a boolean expression instead of an `if..else` block",
963 name: "match_overlapping_arm",
965 desc: "a match with overlapping arms",
970 name: "match_ref_pats",
972 desc: "a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression",
977 name: "match_same_arms",
979 desc: "`match` with identical arm bodies",
984 name: "match_wild_err_arm",
986 desc: "a match with `Err(_)` arm and take drastic actions",
991 name: "maybe_infinite_iter",
993 desc: "possible infinite iteration",
995 module: "infinite_iter",
998 name: "mem_discriminant_non_enum",
999 group: "correctness",
1000 desc: "calling mem::descriminant on non-enum type",
1002 module: "mem_discriminant",
1006 group: "restriction",
1007 desc: "`mem::forget` usage on `Drop` types, likely to cause memory leaks",
1009 module: "mem_forget",
1012 name: "mem_replace_option_with_none",
1014 desc: "replacing an `Option` with `None` instead of `take()`",
1016 module: "mem_replace",
1020 group: "correctness",
1021 desc: "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant",
1026 name: "misrefactored_assign_op",
1027 group: "complexity",
1028 desc: "having a variable on both sides of an assign op",
1030 module: "assign_ops",
1033 name: "missing_const_for_fn",
1035 desc: "Lint functions definitions that could be made `const fn`",
1037 module: "missing_const_for_fn",
1040 name: "missing_docs_in_private_items",
1041 group: "restriction",
1042 desc: "detects missing documentation for public and private members",
1044 module: "missing_doc",
1047 name: "missing_inline_in_public_items",
1048 group: "restriction",
1049 desc: "detects missing #[inline] attribute for public callables (functions, trait methods, methods...)",
1051 module: "missing_inline",
1054 name: "mistyped_literal_suffixes",
1055 group: "correctness",
1056 desc: "mistyped literal suffix",
1058 module: "literal_representation",
1061 name: "mixed_case_hex_literals",
1063 desc: "hex literals whose letter digits are not consistently upper- or lowercased",
1065 module: "misc_early",
1068 name: "module_inception",
1070 desc: "modules that have the same name as their parent module",
1072 module: "enum_variants",
1075 name: "module_name_repetitions",
1077 desc: "type names prefixed/postfixed with their containing module\'s name",
1079 module: "enum_variants",
1083 group: "correctness",
1084 desc: "taking a number modulo 1, which always returns 0",
1089 name: "multiple_crate_versions",
1091 desc: "multiple versions of the same crate being used",
1093 module: "multiple_crate_versions",
1096 name: "multiple_inherent_impl",
1097 group: "restriction",
1098 desc: "Multiple inherent impl that could be grouped",
1100 module: "inherent_impl",
1103 name: "mut_from_ref",
1104 group: "correctness",
1105 desc: "fns that create mutable refs from immutable ref args",
1112 desc: "usage of double-mut refs, e.g., `&mut &mut ...`",
1117 name: "mut_range_bound",
1118 group: "complexity",
1119 desc: "for loop over a range where one of the bounds is a mutable variable",
1124 name: "mutex_atomic",
1126 desc: "using a mutex where an atomic value could be used instead",
1128 module: "mutex_atomic",
1131 name: "mutex_integer",
1133 desc: "using a mutex for an integer type",
1135 module: "mutex_atomic",
1138 name: "naive_bytecount",
1140 desc: "use of naive `<slice>.filter(|&x| x == y).count()` to count byte values",
1142 module: "bytecount",
1145 name: "needless_bool",
1146 group: "complexity",
1147 desc: "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`",
1149 module: "needless_bool",
1152 name: "needless_borrow",
1154 desc: "taking a reference that is going to be automatically dereferenced",
1156 module: "needless_borrow",
1159 name: "needless_borrowed_reference",
1160 group: "complexity",
1161 desc: "taking a needless borrowed reference",
1163 module: "needless_borrowed_ref",
1166 name: "needless_collect",
1168 desc: "collecting an iterator when collect is not needed",
1173 name: "needless_continue",
1175 desc: "`continue` statements that can be replaced by a rearrangement of code",
1177 module: "needless_continue",
1180 name: "needless_lifetimes",
1181 group: "complexity",
1182 desc: "using explicit lifetimes for references in function arguments when elision rules would allow omitting them",
1184 module: "lifetimes",
1187 name: "needless_pass_by_value",
1189 desc: "functions taking arguments by value, but not consuming them in its body",
1191 module: "needless_pass_by_value",
1194 name: "needless_range_loop",
1196 desc: "for-looping over a range of indices where an iterator over items would do",
1201 name: "needless_return",
1203 desc: "using a return statement like `return expr;` where an expression would suffice",
1208 name: "needless_update",
1209 group: "complexity",
1210 desc: "using `Foo { ..base }` when there are no missing fields",
1212 module: "needless_update",
1215 name: "neg_cmp_op_on_partial_ord",
1216 group: "complexity",
1217 desc: "The use of negated comparison operators on partially ordered types may produce confusing code.",
1219 module: "neg_cmp_op_on_partial_ord",
1222 name: "neg_multiply",
1224 desc: "multiplying integers with -1",
1226 module: "neg_multiply",
1230 group: "correctness",
1231 desc: "any loop that will always `break` or `return`",
1236 name: "new_ret_no_self",
1238 desc: "not returning `Self` in a `new` method",
1243 name: "new_without_default",
1245 desc: "`fn new() -> Self` method without `Default` implementation",
1247 module: "new_without_default",
1251 group: "complexity",
1252 desc: "statements with no effect",
1254 module: "no_effect",
1257 name: "non_ascii_literal",
1259 desc: "using any literal non-ASCII chars in a string literal instead of using the `\\\\u` escape",
1264 name: "nonminimal_bool",
1265 group: "complexity",
1266 desc: "boolean expressions that can be written more concisely",
1271 name: "nonsensical_open_options",
1272 group: "correctness",
1273 desc: "nonsensical combination of options for opening a file",
1275 module: "open_options",
1278 name: "not_unsafe_ptr_arg_deref",
1279 group: "correctness",
1280 desc: "public functions dereferencing raw pointer arguments but not marked `unsafe`",
1282 module: "functions",
1287 desc: "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result",
1294 desc: "taking a reference to satisfy the type constraints on `==`",
1299 name: "option_map_or_none",
1301 desc: "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`",
1306 name: "option_map_unit_fn",
1307 group: "complexity",
1308 desc: "using `option.map(f)`, where f is a function or closure that returns ()",
1310 module: "map_unit_fn",
1313 name: "option_map_unwrap_or",
1315 desc: "using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as `map_or(a, f)`",
1320 name: "option_map_unwrap_or_else",
1322 desc: "using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`",
1327 name: "option_option",
1328 group: "complexity",
1329 desc: "usage of `Option<Option<T>>`",
1334 name: "option_unwrap_used",
1335 group: "restriction",
1336 desc: "using `Option.unwrap()`, which should at least get a better message using `expect()`",
1341 name: "or_fun_call",
1343 desc: "using any `*or` method with a function call, which suggests `*or_else`",
1348 name: "out_of_bounds_indexing",
1349 group: "correctness",
1350 desc: "out of bounds constant indexing",
1352 module: "indexing_slicing",
1355 name: "overflow_check_conditional",
1356 group: "complexity",
1357 desc: "overflow checks inspired by C which are likely to panic",
1359 module: "overflow_check_conditional",
1362 name: "panic_params",
1364 desc: "missing parameters in `panic!` calls",
1366 module: "panic_unimplemented",
1369 name: "panicking_unwrap",
1371 desc: "checks for calls of unwrap[_err]() that will always fail",
1376 name: "partialeq_ne_impl",
1377 group: "complexity",
1378 desc: "re-implementing `PartialEq::ne`",
1380 module: "partialeq_ne_impl",
1383 name: "path_buf_push_overwrite",
1385 desc: "calling `push` with file system root on `PathBuf` can overwrite it",
1387 module: "path_buf_push_overwrite",
1390 name: "possible_missing_comma",
1391 group: "correctness",
1392 desc: "possible missing comma in array",
1394 module: "formatting",
1398 group: "complexity",
1399 desc: "operations where precedence may be unclear",
1401 module: "precedence",
1404 name: "print_literal",
1406 desc: "printing a literal with a format string",
1411 name: "print_stdout",
1412 group: "restriction",
1413 desc: "printing on stdout",
1418 name: "print_with_newline",
1420 desc: "using `print!()` with a format string that ends in a single newline",
1425 name: "println_empty_string",
1427 desc: "using `println!(\"\")` with an empty string",
1434 desc: "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively",
1439 name: "ptr_offset_with_cast",
1440 group: "complexity",
1441 desc: "unneeded pointer offset cast",
1443 module: "ptr_offset_with_cast",
1446 name: "pub_enum_variant_names",
1448 desc: "enums where all variants share a prefix/postfix",
1450 module: "enum_variants",
1453 name: "question_mark",
1455 desc: "checks for expressions that could be replaced by the question mark operator",
1457 module: "question_mark",
1460 name: "range_minus_one",
1461 group: "complexity",
1462 desc: "`x..=(y-1)` reads better as `x..y`",
1467 name: "range_plus_one",
1468 group: "complexity",
1469 desc: "`x..(y+1)` reads better as `x..=y`",
1474 name: "range_zip_with_len",
1475 group: "complexity",
1476 desc: "zipping iterator with a range when `enumerate()` would do",
1481 name: "redundant_clone",
1483 desc: "`clone()` of an owned value that is going to be dropped immediately",
1485 module: "redundant_clone",
1488 name: "redundant_closure",
1490 desc: "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)",
1492 module: "eta_reduction",
1495 name: "redundant_closure_call",
1496 group: "complexity",
1497 desc: "throwaway closures called in the expression they are defined",
1499 module: "misc_early",
1502 name: "redundant_closure_for_method_calls",
1504 desc: "redundant closures for method calls",
1506 module: "eta_reduction",
1509 name: "redundant_field_names",
1511 desc: "checks for fields in struct literals where shorthands could be used",
1513 module: "redundant_field_names",
1516 name: "redundant_pattern",
1518 desc: "using `name @ _` in a pattern",
1523 name: "redundant_pattern_matching",
1525 desc: "use the proper utility function avoiding an `if let`",
1527 module: "redundant_pattern_matching",
1530 name: "redundant_static_lifetimes",
1532 desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.",
1534 module: "redundant_static_lifetimes",
1537 name: "ref_in_deref",
1538 group: "complexity",
1539 desc: "Use of reference in auto dereference expression.",
1541 module: "reference",
1544 name: "regex_macro",
1546 desc: "use of `regex!(_)` instead of `Regex::new(_)`",
1551 name: "replace_consts",
1553 desc: "Lint usages of standard library `const`s that could be replaced by `const fn`s",
1555 module: "replace_consts",
1558 name: "result_map_unit_fn",
1559 group: "complexity",
1560 desc: "using `result.map(f)`, where f is a function or closure that returns ()",
1562 module: "map_unit_fn",
1565 name: "result_map_unwrap_or_else",
1567 desc: "using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.ok().map_or_else(g, f)`",
1572 name: "result_unwrap_used",
1573 group: "restriction",
1574 desc: "using `Result.unwrap()`, which might be better handled",
1579 name: "reverse_range_loop",
1580 group: "correctness",
1581 desc: "iteration over an empty range, such as `10..0` or `5..5`",
1586 name: "search_is_some",
1587 group: "complexity",
1588 desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
1593 name: "serde_api_misuse",
1594 group: "correctness",
1595 desc: "various things that will negatively affect your serde experience",
1597 module: "serde_api",
1600 name: "shadow_reuse",
1601 group: "restriction",
1602 desc: "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`",
1607 name: "shadow_same",
1608 group: "restriction",
1609 desc: "rebinding a name to itself, e.g., `let mut x = &mut x`",
1614 name: "shadow_unrelated",
1616 desc: "rebinding a name without even using the original value",
1621 name: "short_circuit_statement",
1622 group: "complexity",
1623 desc: "using a short circuit boolean condition as a statement",
1628 name: "should_implement_trait",
1630 desc: "defining a method that should be implementing a std trait",
1635 name: "similar_names",
1637 desc: "similarly named items and bindings",
1639 module: "non_expressive_names",
1642 name: "single_char_pattern",
1644 desc: "using a single-character str where a char could be used, e.g., `_.split(\"x\")`",
1649 name: "single_match",
1651 desc: "a match statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`",
1656 name: "single_match_else",
1658 desc: "a match statement with a two arms where the second arm\'s pattern is a placeholder instead of a specific match pattern",
1663 name: "slow_vector_initialization",
1665 desc: "slow vector initialization",
1667 module: "slow_vector_initialization",
1671 group: "restriction",
1672 desc: "using `x + ..` where x is a `String` instead of `push_str()`",
1677 name: "string_add_assign",
1679 desc: "using `x = x + ..` where x is a `String` instead of `push_str()`",
1684 name: "string_extend_chars",
1686 desc: "using `x.extend(s.chars())` where s is a `&str` or `String`",
1691 name: "string_lit_as_bytes",
1693 desc: "calling `as_bytes` on a string literal instead of using a byte string literal",
1698 name: "suspicious_arithmetic_impl",
1699 group: "correctness",
1700 desc: "suspicious use of operators in impl of arithmetic trait",
1702 module: "suspicious_trait_impl",
1705 name: "suspicious_assignment_formatting",
1707 desc: "suspicious formatting of `*=`, `-=` or `!=`",
1709 module: "formatting",
1712 name: "suspicious_else_formatting",
1714 desc: "suspicious formatting of `else`",
1716 module: "formatting",
1719 name: "suspicious_op_assign_impl",
1720 group: "correctness",
1721 desc: "suspicious use of operators in impl of OpAssign trait",
1723 module: "suspicious_trait_impl",
1726 name: "temporary_assignment",
1727 group: "complexity",
1728 desc: "assignments to temporaries",
1730 module: "temporary_assignment",
1733 name: "temporary_cstring_as_ptr",
1734 group: "correctness",
1735 desc: "getting the inner pointer of a temporary `CString`",
1740 name: "too_many_arguments",
1741 group: "complexity",
1742 desc: "functions with too many arguments",
1744 module: "functions",
1747 name: "too_many_lines",
1749 desc: "functions with too many lines",
1751 module: "functions",
1754 name: "toplevel_ref_arg",
1756 desc: "an entire binding declared as `ref`, in a function argument or a `let` statement",
1761 name: "transmute_bytes_to_str",
1762 group: "complexity",
1763 desc: "transmutes from a `&[u8]` to a `&str`",
1765 module: "transmute",
1768 name: "transmute_int_to_bool",
1769 group: "complexity",
1770 desc: "transmutes from an integer to a `bool`",
1772 module: "transmute",
1775 name: "transmute_int_to_char",
1776 group: "complexity",
1777 desc: "transmutes from an integer to a `char`",
1779 module: "transmute",
1782 name: "transmute_int_to_float",
1783 group: "complexity",
1784 desc: "transmutes from an integer to a float",
1786 module: "transmute",
1789 name: "transmute_ptr_to_ptr",
1790 group: "complexity",
1791 desc: "transmutes from a pointer to a pointer / a reference to a reference",
1793 module: "transmute",
1796 name: "transmute_ptr_to_ref",
1797 group: "complexity",
1798 desc: "transmutes from a pointer to a reference type",
1800 module: "transmute",
1803 name: "transmuting_null",
1804 group: "correctness",
1805 desc: "transmutes from a null pointer to a reference, which is undefined behavior",
1807 module: "transmuting_null",
1810 name: "trivial_regex",
1812 desc: "trivial regular expressions",
1817 name: "trivially_copy_pass_by_ref",
1819 desc: "functions taking small copyable arguments by reference",
1821 module: "trivially_copy_pass_by_ref",
1826 desc: "return errors explicitly rather than hiding them behind a `?`",
1831 name: "type_complexity",
1832 group: "complexity",
1833 desc: "usage of very complex types that might be better factored into `type` definitions",
1838 name: "unicode_not_nfc",
1840 desc: "using a unicode literal not in NFC normal form (see [unicode tr15](http://www.unicode.org/reports/tr15/) for further information)",
1845 name: "unimplemented",
1846 group: "restriction",
1847 desc: "`unimplemented!` should not be present in production code",
1849 module: "panic_unimplemented",
1853 group: "complexity",
1854 desc: "passing unit to a function",
1860 group: "correctness",
1861 desc: "comparing unit values",
1866 name: "unknown_clippy_lints",
1868 desc: "unknown_lints for scoped Clippy lints",
1873 name: "unnecessary_cast",
1874 group: "complexity",
1875 desc: "cast to the same type, e.g., `x as i32` where `x: i32`",
1880 name: "unnecessary_filter_map",
1881 group: "complexity",
1882 desc: "using `filter_map` when a more succinct alternative exists",
1887 name: "unnecessary_fold",
1889 desc: "using `fold` when a more succinct alternative exists",
1894 name: "unnecessary_mut_passed",
1896 desc: "an argument passed as a mutable reference although the callee only demands an immutable reference",
1898 module: "mut_reference",
1901 name: "unnecessary_operation",
1902 group: "complexity",
1903 desc: "outer expressions with no effect",
1905 module: "no_effect",
1908 name: "unnecessary_unwrap",
1910 desc: "checks for calls of unwrap[_err]() that cannot fail",
1915 name: "unneeded_field_pattern",
1917 desc: "struct fields bound to a wildcard instead of using `..`",
1919 module: "misc_early",
1922 name: "unreadable_literal",
1924 desc: "long integer literal without underscores",
1926 module: "literal_representation",
1929 name: "unsafe_removed_from_name",
1931 desc: "`unsafe` removed from API names on import",
1933 module: "unsafe_removed_from_name",
1936 name: "unseparated_literal_suffix",
1938 desc: "literals whose suffix is not separated by an underscore",
1940 module: "misc_early",
1943 name: "unused_collect",
1945 desc: "`collect()`ing an iterator without using the result; this is usually better written as a for loop",
1950 name: "unused_io_amount",
1951 group: "correctness",
1952 desc: "unused written/read amount",
1954 module: "unused_io_amount",
1957 name: "unused_label",
1958 group: "complexity",
1959 desc: "unused labels",
1961 module: "unused_label",
1964 name: "unused_unit",
1966 desc: "needless unit expression",
1972 group: "restriction",
1973 desc: "use of `Debug`-based formatting",
1980 desc: "Unnecessary structure name repetition whereas `Self` is applicable",
1985 name: "used_underscore_binding",
1987 desc: "using a binding which is prefixed with an underscore",
1992 name: "useless_asref",
1993 group: "complexity",
1994 desc: "using `as_ref` where the types before and after the call are the same",
1999 name: "useless_attribute",
2000 group: "correctness",
2001 desc: "use of lint attributes on `extern crate` items",
2006 name: "useless_format",
2007 group: "complexity",
2008 desc: "useless use of `format!`",
2013 name: "useless_let_if_seq",
2015 desc: "unidiomatic `let mut` declaration followed by initialization in `if`",
2017 module: "let_if_seq",
2020 name: "useless_transmute",
2021 group: "complexity",
2022 desc: "transmutes that have the same to and from types or could be a cast/coercion",
2024 module: "transmute",
2027 name: "useless_vec",
2029 desc: "useless `vec!`",
2035 group: "complexity",
2036 desc: "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap",
2041 name: "verbose_bit_mask",
2043 desc: "expressions where a bit mask is less readable than the corresponding method call",
2048 name: "while_immutable_condition",
2049 group: "correctness",
2050 desc: "variables used within while expression are not mutated in the body",
2055 name: "while_let_loop",
2056 group: "complexity",
2057 desc: "`loop { if let { ... } else break }`, which can be written as a `while let` loop",
2062 name: "while_let_on_iterator",
2064 desc: "using a while-let loop instead of a for loop on an iterator",
2069 name: "wildcard_dependencies",
2071 desc: "wildcard dependencies being used",
2073 module: "wildcard_dependencies",
2076 name: "wildcard_enum_match_arm",
2077 group: "restriction",
2078 desc: "a wildcard enum match arm using `_`",
2083 name: "write_literal",
2085 desc: "writing a literal with a format string",
2090 name: "write_with_newline",
2092 desc: "using `write!()` with a format string that ends in a single newline",
2097 name: "writeln_empty_string",
2099 desc: "using `writeln!(buf, \"\")` with an empty string",
2104 name: "wrong_pub_self_convention",
2105 group: "restriction",
2106 desc: "defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2111 name: "wrong_self_convention",
2113 desc: "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention",
2118 name: "wrong_transmute",
2119 group: "correctness",
2120 desc: "transmutes that are confusing at best, undefined behaviour at worst and always useless",
2122 module: "transmute",
2125 name: "zero_divided_by_zero",
2126 group: "complexity",
2127 desc: "usage of `0.0 / 0.0` to obtain NaN instead of std::f32::NaN or std::f64::NaN",
2129 module: "zero_div_zero",
2132 name: "zero_prefixed_literal",
2133 group: "complexity",
2134 desc: "integer literals starting with `0`",
2136 module: "misc_early",
2141 desc: "using 0 as *{const, mut} T",
2146 name: "zero_width_space",
2147 group: "correctness",
2148 desc: "using a zero-width space in a string literal, which is confusing",
2153 // end lint list, do not remove this comment, it’s used in `update_lints`