Nothing. from_iter_instead_of_collect
This lint has been deprecated Clippy puts this lint in the deprecated group, at the level none.
- Code
from_iter_instead_of_collect- Severity
- none
- Since
- 1.98.0
According the std docs implementing From<..> is preferred since it gives you Into<..> for free where the reverse isn’t true. Clippy puts this lint in the style group, at the level warn.
- Code
from_over_into- Severity
- warn
- Since
- 1.51.0
When dealing with c_void raw pointers in FFI, it is easy to run into the pitfall of calling from_raw with the c_void pointer. The type signature of Box::from_raw is fn from_raw(raw: *mut T) -> Box<T>, so if you pass a *mut c_void you will get a Box<c_void> (and similarly for Rc, Arc and Weak). For this to be safe, c_void would need to have the same memory layout as the original type, which is often not the case. Clippy puts this lint in the suspicious group, at the level warn.
- Code
from_raw_with_void_ptr- Severity
- warn
- Since
- 1.67.0
This specific common use case can be rewritten as s.parse::<primitive>() (and in most cases, the turbofish can be removed), which reduces code length and complexity. Clippy puts this lint in the style group, at the level warn.
- Code
from_str_radix_10- Severity
- warn
- Since
- 1.52.0
A Future implementation captures some state that it needs to eventually produce its final value. When targeting a multithreaded executor (which is the norm on non-embedded devices) this means that this state may need to be transported to other threads, in other words the whole Future needs to implement the Send marker trait. If it does not, then the resulting Future cannot be submitted to a thread pool in the end user’s code. Clippy puts this lint in the nursery group, at the level allow.
- Code
future_not_send- Severity
- allow
- Since
- 1.44.0
Using x.first() for Vecs and slices or x.front() for VecDeques is easier to read and has the same result. Clippy puts this lint in the style group, at the level warn.
- Code
get_first- Severity
- warn
- Since
- 1.63.0
Using x.last() is easier to read and has the same result. Clippy puts this lint in the complexity group, at the level warn.
- Code
get_last_with_len- Severity
- warn
- Since
- 1.37.0
Using the Index trait ([]) is more clear and more concise. Clippy puts this lint in the restriction group, at the level allow.
- Code
get_unwrap- Severity
- allow
To ensure use of explicitly chosen endianness rather than the target’s endianness, such as when implementing network protocols or file formats rather than FFI. Clippy puts this lint in the restriction group, at the level allow.
- Code
host_endian_bytes- Severity
- allow
- Since
- 1.72.0
This code can be removed without changing the meaning. So it just obscures what’s going on. Delete it mercilessly. Clippy puts this lint in the complexity group, at the level warn.
- Code
identity_op- Severity
- warn
The Mutex lock remains held for the whole if let ... else block and deadlocks. Clippy puts this lint in the correctness group, at the level deny.
- Code
if_let_mutex- Severity
- deny
- Since
- 1.45.0
Negations reduce the readability of statements. Clippy puts this lint in the pedantic group, at the level allow.
- Code
if_not_else- Severity
- allow
This is probably a copy & paste error. Clippy puts this lint in the style group, at the level warn.
- Code
if_same_then_else- Severity
- warn
Looks a little redundant. Using bool::then is more concise and incurs no loss of clarity. For simple calculations and known values, use bool::then_some, which is eagerly evaluated in comparison to bool::then. Clippy puts this lint in the restriction group, at the level allow.
- Code
if_then_some_else_none- Severity
- allow
- Since
- 1.53.0
This is probably a copy & paste error. Clippy puts this lint in the correctness group, at the level deny.
- Code
ifs_same_cond- Severity
- deny
The reason for ignoring the test may not be obvious. Clippy puts this lint in the pedantic group, at the level allow.
- Code
ignore_without_reason- Severity
- allow
- Since
- 1.88.0
Matching with () explicitly instead of _ outlines the fact that the pattern contains no data. Also it would detect a type change that _ would ignore. Clippy puts this lint in the pedantic group, at the level allow.
- Code
ignored_unit_patterns- Severity
- allow
- Since
- 1.73.0
When providing implementations for Borrow<T>, one should consider whether the different implementations should act as facets or representations of the underlying type. Generic code typically uses Borrow<T> when it relies on the identical behavior of these additional trait implementations. These traits will likely appear as additional trait bounds. Clippy puts this lint in the correctness group, at the level deny.
- Code
impl_hash_borrow_with_str_and_bytes- Severity
- deny
- Since
- 1.76.0
Turbofish syntax (::<>) cannot be used to specify the type of an impl Trait parameter, making impl Trait less powerful. Readability may also be a factor. Clippy puts this lint in the restriction group, at the level allow.
- Code
impl_trait_in_params- Severity
- allow
- Since
- 1.69.0
These methods do the same thing as _.clone() but may be confusing as to why we are calling to_vec on something that is already a Vec or calling to_owned on something that is already owned. Clippy puts this lint in the pedantic group, at the level allow.
- Code
implicit_clone- Severity
- allow
- Since
- 1.52.0
HashMap or HashSet with custom hashers cannot be used with them. Clippy puts this lint in the pedantic group, at the level allow.
- Code
implicit_hasher- Severity
- allow
Omitting the return keyword whenever possible is idiomatic Rust code, but: Clippy puts this lint in the restriction group, at the level allow.
- Code
implicit_return- Severity
- allow
- Since
- 1.33.0
The built-in function is more readable and may be faster. Clippy puts this lint in the style group, at the level warn.
- Code
implicit_saturating_add- Severity
- warn
- Since
- 1.66.0
Simplicity and readability. Instead we can easily use an builtin function. Clippy puts this lint in the style group, at the level warn.
- Code
implicit_saturating_sub- Severity
- warn
- Since
- 1.44.0
This can happen when a trait is specified that another trait already has as a supertrait (e.g. fn() -> impl Deref + DerefMut<Target = i32> has an unnecessary Deref bound, because Deref is a supertrait of DerefMut) Specifying more bounds than necessary adds needless complexity for the reader. Clippy puts this lint in the complexity group, at the level warn.
- Code
implied_bounds_in_impls- Severity
- warn
- Since
- 1.74.0
The whole expression can be replaced by false, which is probably not the programmer’s intention Clippy puts this lint in the correctness group, at the level deny.
- Code
impossible_comparisons- Severity
- deny
- Since
- 1.73.0
Negatively impacts accuracy. Clippy puts this lint in the nursery group, at the level allow.
- Code
imprecise_flops- Severity
- allow
- Since
- 1.43.0
It would prevent the crate to be actually used with the specified MSRV. Clippy puts this lint in the suspicious group, at the level warn.
- Code
incompatible_msrv- Severity
- warn
- Since
- 1.78.0
Readers may incorrectly interpret inconsistently grouped digits. Clippy puts this lint in the style group, at the level warn.
- Code
inconsistent_digit_grouping- Severity
- warn
Since the order of fields in a constructor doesn’t affect the resulted instance as the below example indicates, Clippy puts this lint in the pedantic group, at the level allow.
- Code
inconsistent_struct_constructor- Severity
- allow
- Since
- 1.52.0
Accessing slice values using indices can lead to panics. Using refutable patterns can avoid these. Binding to individual values also improves the readability as they can be named. Clippy puts this lint in the pedantic group, at the level allow.
- Code
index_refutable_slice- Severity
- allow
- Since
- 1.59.0
To avoid implicit panics from indexing and slicing. Clippy puts this lint in the restriction group, at the level allow.
- Code
indexing_slicing- Severity
- allow
The basic structure can be seen in the following table: Not equally evil as bad_bit_mask, but still a bit misleading, because the bit mask is ineffective. Clippy puts this lint in the correctness group, at the level deny.
- Code
ineffective_bit_mask- Severity
- deny
.append(true) already enables write(true), making this one superfluous. Clippy puts this lint in the suspicious group, at the level warn.
- Code
ineffective_open_options- Severity
- warn
- Since
- 1.76.0
In versions of the compiler before Rust 1.82.0, this bypasses the specialized implementation of ToString and instead goes through the more expensive string formatting facilities. Clippy puts this lint in the pedantic group, at the level allow.
- Code
inefficient_to_string- Severity
- allow
- Since
- 1.40.0
Just readability – let doesn’t nest, whereas a match does. Clippy puts this lint in the style group, at the level warn.
- Code
infallible_destructuring_match- Severity
- warn
Infallible conversions should be implemented via From with the blanket conversion. Clippy puts this lint in the suspicious group, at the level warn.
- Code
infallible_try_from- Severity
- warn
- Since
- 1.89.0
While there may be places where this is acceptable (e.g., in event streams), in most cases this is simply an error. Clippy puts this lint in the correctness group, at the level deny.
- Code
infinite_iter- Severity
- deny
Making the return type ! serves as documentation that the function does not return. If the function is not intended to loop infinitely, then this lint may detect a bug. Clippy puts this lint in the restriction group, at the level allow.
- Code
infinite_loop- Severity
- allow
- Since
- 1.76.0
This method is also implicitly defined if a type implements the Display trait. As the functionality of Display is much more versatile, it should be preferred. Clippy puts this lint in the style group, at the level warn.
- Code
inherent_to_string- Severity
- warn
- Since
- 1.38.0
This method is also implicitly defined if a type implements the Display trait. The less versatile inherent method will then shadow the implementation introduced by Display. Clippy puts this lint in the correctness group, at the level deny.
- Code
inherent_to_string_shadow_display- Severity
- deny
- Since
- 1.38.0
It will however not lint if a base initializer is present. The lint will also ignore code in macros. This may be confusing to the uninitiated and adds no benefit as opposed to tuple initializers Clippy puts this lint in the style group, at the level warn.
- Code
init_numbered_fields- Severity
- warn
- Since
- 1.59.0
While there are valid uses of this annotation (and once you know when to use it, by all means allow this lint), it’s a common newbie-mistake to pepper one’s code with it. Clippy puts this lint in the pedantic group, at the level allow.
- Code
inline_always- Severity
- allow
To enforce consistent use of Intel x86 assembly syntax. Clippy puts this lint in the restriction group, at the level allow.
- Code
inline_asm_x86_att_syntax- Severity
- allow
- Since
- 1.49.0
To enforce consistent use of AT&T x86 assembly syntax. Clippy puts this lint in the restriction group, at the level allow.
- Code
inline_asm_x86_intel_syntax- Severity
- allow
- Since
- 1.49.0
Only implementations of trait methods may be inlined. The inline attribute is ignored for trait methods without bodies. Clippy puts this lint in the correctness group, at the level deny.
- Code
inline_fn_without_body- Severity
- deny
Inline test modules (anything annotated with #[cfg(test)]) are not linted. Having multiple module layout styles in a project can be confusing. Clippy puts this lint in the restriction group, at the level allow.
- Code
inline_modules- Severity
- allow
- Since
- 1.97.0
Enforce a single style throughout a codebase. Avoid uncertainty about whether a bound should be inline or out-of-line (i.e. a where bound). Avoid complex inline bounds, which could make a function declaration more difficult to read. Clippy puts this lint in the restriction group, at the level allow.
- Code
inline_trait_bounds- Severity
- allow
- Since
- 1.97.0
It is the same as performing the computation inside inspect at the beginning of the closure in for_each. Clippy puts this lint in the complexity group, at the level warn.
- Code
inspect_for_each- Severity
- warn
- Since
- 1.51.0
Readability – better to use > y instead of >= y + 1. Clippy puts this lint in the complexity group, at the level warn.
- Code
int_plus_one- Severity
- warn
When outside of some very specific algorithms, integer division is very often a mistake because it discards the remainder. Clippy puts this lint in the restriction group, at the level allow.
- Code
integer_division- Severity
- allow
- Since
- 1.37.0
In cryptographic contexts, division can result in timing sidechannel vulnerabilities, and needs to be replaced with constant-time code instead (e.g. Barrett reduction). Clippy puts this lint in the restriction group, at the level allow.
- Code
integer_division_remainder_used- Severity
- allow
- Since
- 1.79.0
Readability. Calling into_iter on a reference will not move out its content into the resulting iterator, which is confusing. It is better just call iter or iter_mut directly. Clippy puts this lint in the style group, at the level warn.
- Code
into_iter_on_ref- Severity
- warn
- Since
- 1.32.0
It looks for IntoIterator for (&|&mut) Type implementations without an inherent iter or iter_mut method on the type or on any of the types in its Deref chain. It’s not bad, but having them is idiomatic and allows the type to be used in iterator chains by just calling .iter(), instead of the more awkward <&Type>::into_iter or (&val).into_iter() syntax in case of ambiguity with another IntoIterator impl. Clippy puts this lint in the pedantic group, at the level allow.
- Code
into_iter_without_iter- Severity
- allow
- Since
- 1.75.0
This will lead to a runtime panic. Clippy puts this lint in the correctness group, at the level deny.
- Code
invalid_regex- Severity
- deny
Only integer types are checked. An expression like let x : u8 = ...; (x as u32) > 300 will mistakenly imply that it is possible for x to be outside the range of u8. Clippy puts this lint in the pedantic group, at the level allow.
- Code
invalid_upcast_comparisons- Severity
- allow
This could result in an underflow and is most likely not what the user wants. If this was intended to be a saturated subtraction, consider using the saturating_sub method directly. Clippy puts this lint in the correctness group, at the level deny.
- Code
inverted_saturating_sub- Severity
- deny
- Since
- 1.83.0
Having an invisible character in the code makes for all sorts of April fools, but otherwise is very much frowned upon. Clippy puts this lint in the correctness group, at the level deny.
- Code
invisible_characters- Severity
- deny
- Since
- 1.49.0
Using specific IP addresses like 127.0.0.1 or ::1 is less clear and less maintainable than using the predefined constants Ipv4Addr::LOCALHOST or Ipv6Addr::LOCALHOST. These constants improve code readability, make the intent explicit, and are less error-prone. Clippy puts this lint in the pedantic group, at the level allow.
- Code
ip_constant- Severity
- allow
- Since
- 1.89.0
is_digit(..) is slower and requires specifying the radix. Clippy puts this lint in the style group, at the level warn.
- Code
is_digit_ascii_radix- Severity
- warn
- Since
- 1.62.0
Items live for the entire scope they are declared in. But statements are processed in order. This might cause confusion as it’s hard to figure out which item is meant in a statement. Clippy puts this lint in the pedantic group, at the level allow.
- Code
items_after_statements- Severity
- allow
Having items declared after the testing module is confusing and may lead to bad test coverage. Clippy puts this lint in the style group, at the level warn.
- Code
items_after_test_module- Severity
- warn
- Since
- 1.71.0
.to_vec() is clearer Clippy puts this lint in the style group, at the level warn.
- Code
iter_cloned_collect- Severity
- warn
.len() is more efficient and more readable. Clippy puts this lint in the complexity group, at the level warn.
- Code
iter_count- Severity
- warn
- Since
- 1.52.0
This lint will require additional changes to the follow-up calls as it affects the type. This pattern is often followed by manual unwrapping of Result. The simplification results in more readable and succinct code without the need for manual unwrapping. Clippy puts this lint in the pedantic group, at the level allow.
- Code
iter_filter_is_ok- Severity
- allow
- Since
- 1.77.0
This lint will require additional changes to the follow-up calls as it affects the type. This pattern is often followed by manual unwrapping of the Option. The simplification results in more readable and succinct code without the need for manual unwrapping. Clippy puts this lint in the pedantic group, at the level allow.
- Code
iter_filter_is_some- Severity
- allow
- Since
- 1.77.0
Readability. There are keys and values methods that can be used to express that we only need the keys or the values. Clippy puts this lint in the complexity group, at the level warn.
- Code
iter_kv_map- Severity
- warn
- Since
- 1.66.0
next() returns either Some(value) if there was a value, or None otherwise. The insidious thing is that Option<_> implements IntoIterator, so that possibly one value will be iterated, leading to some hard to find bugs. No one will want to write such code except to win an Underhanded Rust Contest. Clippy puts this lint in the correctness group, at the level deny.
- Code
iter_next_loop- Severity
- deny
These can be shortened into .first() or .first_mut() Clippy puts this lint in the style group, at the level warn.
- Code
iter_next_slice- Severity
- warn
- Since
- 1.46.0
Methods named iter or iter_mut conventionally return an Iterator. Clippy puts this lint in the pedantic group, at the level allow.
- Code
iter_not_returning_iterator- Severity
- allow
- Since
- 1.57.0
.get() and .get_mut() are equivalent but more concise. Clippy puts this lint in the style group, at the level warn.
- Code
iter_nth- Severity
- warn
iter.next() is equivalent to iter.nth(0), as they both consume the next element, but is more readable. Clippy puts this lint in the style group, at the level warn.
- Code
iter_nth_zero- Severity
- warn
- Since
- 1.42.0
It is simpler to use the empty function from the standard library: Clippy puts this lint in the nursery group, at the level allow.
- Code
iter_on_empty_collections- Severity
- allow
- Since
- 1.65.0
It is simpler to use the once function from the standard library: Clippy puts this lint in the nursery group, at the level allow.
- Code
iter_on_single_items- Severity
- allow
- Since
- 1.65.0
Taking or skipping more items than there are in an iterator either creates an iterator with all items from the original iterator or an iterator with no items at all. This is most likely not what the user intended to do. Clippy puts this lint in the suspicious group, at the level warn.
- Code
iter_out_of_bounds- Severity
- warn
- Since
- 1.74.0
Because hash types are unordered, when iterated through such as in a for loop, the values are returned in an undefined order. As a result, on redundant systems this may cause inconsistencies and anomalies. In addition, the unknown order of the elements may reduce readability or introduce other undesired side effects. Clippy puts this lint in the restriction group, at the level allow.
- Code
iter_over_hash_type- Severity
- allow
- Since
- 1.76.0
It’s often inefficient to clone all elements of an iterator, when eventually, only some of them will be consumed. Clippy puts this lint in the perf group, at the level warn.
- Code
iter_overeager_cloned- Severity
- warn
- Since
- 1.60.0
.nth(x) is cleaner Clippy puts this lint in the style group, at the level warn.
- Code
iter_skip_next- Severity
- warn
This was likely intended to be .skip(1) to skip the first element, as .skip(0) does nothing. If not, the call should be removed. Clippy puts this lint in the correctness group, at the level deny.
- Code
iter_skip_zero- Severity
- deny
- Since
- 1.73.0
.into_iter() is simpler with better performance. Clippy puts this lint in the nursery group, at the level allow.
- Code
iter_with_drain- Severity
- allow
- Since
- 1.61.0
It’s not bad, but having them is idiomatic and allows the type to be used in for loops directly (for val in &iter {}), without having to first call iter() or iter_mut(). Clippy puts this lint in the pedantic group, at the level allow.
- Code
iter_without_into_iter- Severity
- allow
- Since
- 1.75.0
This very much looks like an oversight. Use panic!() instead if you actually intend to panic. Clippy puts this lint in the correctness group, at the level deny.
- Code
iterator_step_by_zero- Severity
- deny
If the argument to Path::join starts with a separator, it will overwrite the original path. If this is intentional, prefer using Path::new instead. Clippy puts this lint in the suspicious group, at the level warn.
- Code
join_absolute_paths- Severity
- warn
- Since
- 1.76.0
It’s hard to memorize what a variable means without a descriptive name. Clippy puts this lint in the style group, at the level warn.
- Code
just_underscores_and_digits- Severity
- warn
Performance: const variables are inlined upon use. Static items result in only one instance and has a fixed location in memory. Clippy puts this lint in the perf group, at the level warn.
- Code
large_const_arrays- Severity
- warn
- Since
- 1.44.0
Negatively impacts readability. Clippy puts this lint in the pedantic group, at the level allow.
- Code
large_digit_groups- Severity
- allow
Enum size is bounded by the largest variant. Having one large variant can penalize the memory layout of that enum. Clippy puts this lint in the perf group, at the level warn.
- Code
large_enum_variant- Severity
- warn
Due to the current unideal implementation of Coroutine, large size of a Future may cause stack overflows. Clippy puts this lint in the pedantic group, at the level allow.
- Code
large_futures- Severity
- allow
- Since
- 1.70.0
Including large files can undesirably increase the size of the binary produced by the compiler. This lint may be used to catch mistakes where an unexpectedly large file is included, or temporarily to obtain a list of all large files. Clippy puts this lint in the restriction group, at the level allow.
- Code
large_include_file- Severity
- allow
- Since
- 1.62.0
Large local arrays may cause stack overflow. Clippy puts this lint in the pedantic group, at the level allow.
- Code
large_stack_arrays- Severity
- allow
- Since
- 1.41.0
The stack region of memory is very limited in size (usually much smaller than the heap) and attempting to use too much will result in a stack overflow and crash the program. To avoid this, you should consider allocating large types on the heap instead (e.g. by boxing them). Clippy puts this lint in the nursery group, at the level allow.
- Code
large_stack_frames- Severity
- allow
- Since
- 1.72.0
Does not trigger if the function is being exported, because that might induce API breakage, if the parameter is declared as mutable, or if the argument is a self. Arguments passed by value might result in an unnecessary shallow copy, taking up more space in the stack and requiring a call to memcpy, which can be expensive. Clippy puts this lint in the pedantic group, at the level allow.
- Code
large_types_passed_by_value- Severity
- allow
- Since
- 1.49.0
All of these have been superseded by the associated constants on their respective types, such as i128::MAX. These legacy items may be deprecated in a future version of rust. Clippy puts this lint in the style group, at the level warn.
- Code
legacy_numeric_constants- Severity
- warn
- Since
- 1.79.0
It is good custom to have both methods, because for some data structures, asking about the length will be a costly operation, whereas .is_empty() can usually answer in constant time. Also it used to lead to false positives on the len_zero lint – currently that lint will ignore such entities. Clippy puts this lint in the style group, at the level warn.
- Code
len_without_is_empty- Severity
- warn
Some structures can answer .is_empty() much faster than calculating their length. So it is good to get into the habit of using .is_empty(), and having it is cheap. Besides, it makes the intent clearer than a manual comparison in some contexts. Clippy puts this lint in the style group, at the level warn.
- Code
len_zero- Severity
- warn
It is just extraneous code. Remove it to make your code more rusty. Clippy puts this lint in the style group, at the level warn.
- Code
let_and_return- Severity
- warn
Futures must be polled for work to be done. The original intention was most likely to await the future and ignore the resulting value. Clippy puts this lint in the suspicious group, at the level warn.
- Code
let_underscore_future- Severity
- warn
- Since
- 1.67.0
This supports mutex and rwlock in parking_lot. For std locks see the rustc lint let_underscore_lock This statement immediately drops the lock instead of extending its lifetime to the end of the scope, which is often not intended. To extend lock lifetime to the end of the scope, use an underscore-prefixed name instead (i.e. _lock). If you want to explicitly drop the lock, std::mem::drop conveys your intention better and is less error-prone. Clippy puts this lint in the correctness group, at the level deny.
- Code
let_underscore_lock- Severity
- deny
- Since
- 1.43.0
To ensure that all #[must_use] types are used rather than ignored. Clippy puts this lint in the restriction group, at the level allow.
- Code
let_underscore_must_use- Severity
- allow
- Since
- 1.42.0
The let _ = <expr> expression ignores the value of <expr>, but will continue to do so even if the type were to change, thus potentially introducing subtle bugs. By supplying a type annotation, one will be forced to re-visit the decision to ignore the value in such cases. Clippy puts this lint in the restriction group, at the level allow.
- Code
let_underscore_untyped- Severity
- allow
- Since
- 1.69.0
A unit value cannot usefully be used anywhere. So binding one is kind of pointless. Clippy puts this lint in the style group, at the level warn.
- Code
let_unit_value- Severity
- warn
It adds noise, : _ provides zero clarity or utility. Clippy puts this lint in the complexity group, at the level warn.
- Code
let_with_type_underscore- Severity
- warn
- Since
- 1.70.0
Lines instances might produce a never-ending stream of Err, in which case filter_map(Result::ok) will enter an infinite loop while waiting for an Ok variant. Calling next() once is sufficient to enter the infinite loop, even in the absence of explicit loops in the user code. Clippy puts this lint in the suspicious group, at the level warn.
- Code
lines_filter_map_ok- Severity
- warn
- Since
- 1.70.0
Gankra says: Clippy puts this lint in the pedantic group, at the level allow.
- Code
linkedlist- Severity
- allow
The order of lints in the [lints] is ignored, to have a lint override a group the priority field needs to be used, otherwise the sort order is undefined. Clippy puts this lint in the correctness group, at the level deny.
- Code
lint_groups_priority- Severity
- deny
- Since
- 1.78.0
It will likely not generate the expected content. Clippy puts this lint in the nursery group, at the level allow.
- Code
literal_string_with_formatting_args- Severity
- allow
- Since
- 1.85.0
To ensure use of big-endian or the target’s endianness rather than little-endian. Clippy puts this lint in the restriction group, at the level allow.
- Code
little_endian_bytes- Severity
- allow
- Since
- 1.72.0
If the value was intended to be exact, it will not be. This may be especially surprising when the lost precision is to the left of the decimal point. Clippy puts this lint in the restriction group, at the level allow.
- Code
lossy_float_literal- Severity
- allow
- Since
- 1.43.0
This hides an unsafe block and allows the user of the macro to write unsafe code without an explicit unsafe block at callsite, making it possible to perform unsafe operations in seemingly safe code. Clippy puts this lint in the suspicious group, at the level warn.
- Code
macro_metavars_in_unsafe- Severity
- warn
- Since
- 1.80.0
Since the Rust 2018 edition you can import macro’s directly, this is considered idiomatic. Clippy puts this lint in the pedantic group, at the level allow.
- Code
macro_use_imports- Severity
- allow
- Since
- 1.44.0
Apart from special setups (which we could detect following attributes like #![no_std]), recursing into main() seems like an unintuitive anti-pattern we should be able to detect. Clippy puts this lint in the style group, at the level warn.
- Code
main_recursion- Severity
- warn
- Since
- 1.38.0
Using abs_diff is shorter, more readable, and avoids control flow. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_abs_diff- Severity
- warn
- Since
- 1.88.0
assert! is simpler than if-then-panic!. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_assert- Severity
- allow
- Since
- 1.57.0
assert_{eq,ne}! and debug_assert_{eq,ne}! achieves the same goal, and provides some additional debug information Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_assert_eq- Severity
- allow
- Since
- 1.97.0
It’s more idiomatic to use the dedicated syntax. Clippy puts this lint in the style group, at the level warn.
- Code
manual_async_fn- Severity
- warn
- Since
- 1.45.0
Manual reimplementations of bit_width increase code complexity for little benefit. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_bit_width- Severity
- allow
- Since
- 1.98.0
Can be written as the shorter T::BITS. Clippy puts this lint in the style group, at the level warn.
- Code
manual_bits- Severity
- warn
- Since
- 1.60.0
This can be written more concisely using c"str" literals and is also less error-prone, because the compiler checks for interior NUL bytes and the terminating NUL byte is inserted automatically. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_c_str_literals- Severity
- warn
- Since
- 1.78.0
checked_div already handles the zero case and makes the intent clearer while avoiding a panic from a manual division. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_checked_ops- Severity
- warn
- Since
- 1.95.0
clamp is much shorter, easier to read, and doesn’t use any control flow. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_clamp- Severity
- warn
- Since
- 1.66.0
clear() expresses the intent better and is likely to be more efficient than truncate(0). Clippy puts this lint in the perf group, at the level warn.
- Code
manual_clear- Severity
- warn
- Since
- 1.97.0
contains() is more concise and idiomatic, while also being faster in some cases. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_contains- Severity
- warn
- Since
- 1.87.0
This creates a dangling pointer and is better expressed as {std, core}::ptr::{dangling, dangling_mut}. Clippy puts this lint in the style group, at the level warn.
- Code
manual_dangling_ptr- Severity
- warn
- Since
- 1.88.0
It’s simpler, clearer and more readable. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_div_ceil- Severity
- warn
- Since
- 1.83.0
Using the filter method is clearer and more concise. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_filter- Severity
- warn
- Since
- 1.66.0
Redundant code in the filter and map operations is poor style and less performant. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_filter_map- Severity
- warn
- Since
- 1.51.0
It doesn’t affect performance, but using find is shorter and easier to read. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_find- Severity
- warn
- Since
- 1.64.0
Redundant code in the find and map operations is poor style and less performant. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_find_map- Severity
- warn
- Since
- 1.51.0
It is verbose and can be simplified by first calling the flatten method on the Iterator. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_flatten- Severity
- warn
- Since
- 1.52.0
It is more concise to use the hash_one method. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_hash_one- Severity
- warn
- Since
- 1.75.0
The eq_ignore_ascii_case method is faster because it does not allocate memory for the new strings, and it is more readable. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_ignore_case_cmp- Severity
- warn
- Since
- 1.84.0
Manual reimplementations of ilog2 increase code complexity for little benefit. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_ilog2- Severity
- allow
- Since
- 1.94.0
inspect is both clearer in intent and shorter. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_inspect- Severity
- warn
- Since
- 1.81.0
It is easy to accidentally write prev_instant - Instant::now(), which will always be 0ns as Instant subtraction saturates. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_instant_elapsed- Severity
- allow
- Since
- 1.65.0
Using the built-in functions is more readable and makes it clear that it’s not a specific subset of characters, but all ASCII (lowercase|uppercase|digit|hexdigit) characters. Clippy puts this lint in the style group, at the level warn.
- Code
manual_is_ascii_check- Severity
- warn
- Since
- 1.67.0
The method is_finite is shorter and more readable. Clippy puts this lint in the style group, at the level warn.
- Code
manual_is_finite- Severity
- warn
- Since
- 1.73.0
The method is_infinite is shorter and more readable. Clippy puts this lint in the style group, at the level warn.
- Code
manual_is_infinite- Severity
- warn
- Since
- 1.73.0
a.is_multiple_of(b) is a clearer way to check for divisibility of a by b. This expression can never panic. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_is_multiple_of- Severity
- warn
- Since
- 1.90.0
Manual reimplementations of is_power_of_two increase code complexity for little benefit. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_is_power_of_two- Severity
- allow
- Since
- 1.83.0
Readability. These can be written more concisely as option.is_some_and(f) and result.is_ok_and(f). Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_is_variant_and- Severity
- allow
- Since
- 1.77.0
The manual bit-twiddling forms are harder to read than the standard library method. Using -x can also overflow for signed minimum values. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_isolate_lowest_one- Severity
- warn
- Since
- 1.98.0
let...else provides a standard construct for this pattern that people can easily recognize. It’s also more compact. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_let_else- Severity
- allow
- Since
- 1.67.0
There exists a std::path::MAIN_SEPARATOR_STR which does not require an extra memory allocation. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_main_separator_str- Severity
- warn
- Since
- 1.70.0
Using the map method is clearer and more concise. Clippy puts this lint in the style group, at the level warn.
- Code
manual_map- Severity
- warn
- Since
- 1.52.0
It is not as fast as a memcpy. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_memcpy- Severity
- warn
Using (x + y) / 2 or (x + y) >> 1 on integer types might cause an overflow on the intermediate addition result. The latter will only warn for unsigned integer types. Similar for floating-point (x + y) / 2.0 and (x + y) * 0.5. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_midpoint- Severity
- allow
- Since
- 1.87.0
.next_back() is cleaner. Clippy puts this lint in the style group, at the level warn.
- Code
manual_next_back- Severity
- warn
- Since
- 1.71.0
Using the #[non_exhaustive] attribute expresses better the intent and allows possible optimizations when applied to enums. Clippy puts this lint in the style group, at the level warn.
- Code
manual_non_exhaustive- Severity
- warn
- Since
- 1.45.0
Waker::noop() provides a more performant and cleaner way to create a waker that does nothing, avoiding unnecessary Arc allocations and reference count increments. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_noop_waker- Severity
- warn
- Since
- 1.96.0
Using .ok() or .err() rather than a match or if let is less complex and more readable. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_ok_err- Severity
- warn
- Since
- 1.86.0
Concise code helps focusing on behavior instead of boilerplate. Clippy puts this lint in the style group, at the level warn.
- Code
manual_ok_or- Severity
- warn
- Since
- 1.49.0
Those implementations are both more complex than calling as_slice and unlike that incur a branch, pessimizing performance and leading to more generated code. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_option_as_slice- Severity
- warn
- Since
- 1.86.0
Option::zip is more concise and directly expresses the intent of combining two Option values into a tuple. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_option_zip- Severity
- warn
- Since
- 1.96.0
This can be written more concisely using a char or an array of char. This is more readable and more optimized when comparing to only one char. Clippy puts this lint in the style group, at the level warn.
- Code
manual_pattern_char_comparison- Severity
- warn
- Since
- 1.81.0
Using pop_if is more concise and idiomatic. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_pop_if- Severity
- warn
- Since
- 1.96.0
contains expresses the intent better and has less failure modes (such as fencepost errors or using || instead of &&). Clippy puts this lint in the style group, at the level warn.
- Code
manual_range_contains- Severity
- warn
- Since
- 1.49.0
Using an explicit range is more concise and easier to read. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_range_patterns- Severity
- warn
- Since
- 1.72.0
It’s simpler and more readable. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_rem_euclid- Severity
- warn
- Since
- 1.64.0
Using repeat_n() is more concise and clearer. Also, repeat_n() is sometimes faster than repeat().take() when the type of the element is non-trivial to clone because the original value can be reused for the last .next() call rather than always cloning. Clippy puts this lint in the style group, at the level warn.
- Code
manual_repeat_n- Severity
- warn
- Since
- 1.86.0
.retain() is simpler and avoids needless allocation. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_retain- Severity
- warn
- Since
- 1.64.0
Calling the function better conveys the intent. Clippy puts this lint in the style group, at the level warn.
- Code
manual_rotate- Severity
- warn
- Since
- 1.81.0
These can be written simply with saturating_add/sub methods. Clippy puts this lint in the style group, at the level warn.
- Code
manual_saturating_arithmetic- Severity
- warn
- Since
- 1.39.0
Using the fill method is more idiomatic and concise. Clippy puts this lint in the style group, at the level warn.
- Code
manual_slice_fill- Severity
- warn
- Since
- 1.86.0
Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_slice_size_calculation- Severity
- warn
- Since
- 1.70.0
split_once is both clearer in intent and slightly more efficient. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_split_once- Severity
- warn
- Since
- 1.57.0
These are both harder to read, as well as less performant. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_str_repeat- Severity
- warn
- Since
- 1.54.0
Different ways of creating an empty string makes your code less standardized, which can be confusing. Clippy puts this lint in the pedantic group, at the level allow.
- Code
manual_string_new- Severity
- allow
- Since
- 1.65.0
Using str:strip_{prefix,suffix} is safer and may have better performance as there is no slicing which may panic and the compiler does not need to insert this panic code. It is also sometimes more readable as it removes the need for duplicating or storing the pattern used by str::{starts,ends}_with and in the slicing. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_strip- Severity
- warn
- Since
- 1.48.0
The std::mem::swap function exposes the intent better without deinitializing or copying either variable. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_swap- Severity
- warn
Because the function call is shorter and easier to read. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_take- Severity
- warn
- Since
- 1.95.0
The code should use try_fold instead, which short-circuits on failure, thus opening the door for additional optimizations not possible with fold as rustc can guarantee the function is never called on None, Err, etc., alleviating otherwise necessary checks. It’s also slightly more idiomatic. Clippy puts this lint in the perf group, at the level warn.
- Code
manual_try_fold- Severity
- warn
- Since
- 1.72.0
Concise code helps focusing on behavior instead of boilerplate. Clippy puts this lint in the complexity group, at the level warn.
- Code
manual_unwrap_or- Severity
- warn
- Since
- 1.49.0
It can be done in one call with .unwrap_or_default(). Clippy puts this lint in the suspicious group, at the level warn.
- Code
manual_unwrap_or_default- Severity
- warn
- Since
- 1.79.0
Such loops can be written in a more idiomatic way by using a while-let loop and directly pattern matching on the return value of Vec::pop(). Clippy puts this lint in the style group, at the level warn.
- Code
manual_while_let_some- Severity
- warn
- Since
- 1.71.0
It’s hard to memorize what a variable means without a descriptive name. Clippy puts this lint in the pedantic group, at the level allow.
- Code
many_single_char_names- Severity
- allow
The .all(…) or .any(…) methods can be called directly in place of .map(…). Clippy puts this lint in the complexity group, at the level warn.
- Code
map_all_any_identity- Severity
- warn
- Since
- 1.84.0
Readability, this can be written more concisely Clippy puts this lint in the style group, at the level warn.
- Code
map_clone- Severity
- warn
Using try_for_each instead is more readable and idiomatic. Clippy puts this lint in the style group, at the level warn.
- Code
map_collect_result_unit- Severity
- warn
- Since
- 1.49.0
Using entry is more efficient. Clippy puts this lint in the perf group, at the level warn.
- Code
map_entry- Severity
- warn
This map_err throws away the original error rather than allowing the enum to contain and report the cause of the error. Clippy puts this lint in the restriction group, at the level allow.
- Code
map_err_ignore- Severity
- allow
- Since
- 1.48.0
Readability. This can be written more concisely with Iterator::flat_map, Option::and_then, and Result::and_then. Clippy puts this lint in the complexity group, at the level warn.
- Code
map_flatten- Severity
- warn
- Since
- 1.31.0
It can be written more concisely without the call to map. Clippy puts this lint in the complexity group, at the level warn.
- Code
map_identity- Severity
- warn
- Since
- 1.47.0
This can be written more concisely by using unwrap_or(). Clippy puts this lint in the complexity group, at the level warn.
- Code
map_or_identity- Severity
- warn
- Since
- 1.97.0
Readability, these can be written more concisely (resp.) as option.map_or(_, _), option.map_or_else(_, _) and result.map_or_else(_, _). Clippy puts this lint in the pedantic group, at the level allow.
- Code
map_unwrap_or- Severity
- allow
- Since
- 1.45.0
It expresses the intent more clearly to take the correct number of times from a generating function than to apply a closure to each number in a range only to discard them. Clippy puts this lint in the restriction group, at the level allow.
- Code
map_with_unused_argument_over_ranges- Severity
- allow
- Since
- 1.84.0
Using as_ref() or as_mut() instead is shorter. Clippy puts this lint in the complexity group, at the level warn.
- Code
match_as_ref- Severity
- warn
It suggests to replace the expression with an if...else block. It makes the code less readable. Clippy puts this lint in the pedantic group, at the level allow.
- Code
match_bool- Severity
- allow
Readability and needless complexity. Clippy puts this lint in the style group, at the level warn.
- Code
match_like_matches_macro- Severity
- warn
- Since
- 1.47.0
Nothing. match_on_vec_items
This lint has been deprecated Clippy puts this lint in the deprecated group, at the level none.
- Code
match_on_vec_items- Severity
- none
- Since
- 1.88.0
It is likely to be an error and if not, makes the code less obvious. Clippy puts this lint in the style group, at the level warn.
- Code
match_overlapping_arm- Severity
- warn
It also checks for if let &foo = bar blocks. It just makes the code less readable. That reference destructuring adds nothing to the code. Clippy puts this lint in the style group, at the level warn.
- Code
match_ref_pats- Severity
- warn
Calling ok() in while let is unnecessary, instead match on Ok(pat) Clippy puts this lint in the style group, at the level warn.
- Code
match_result_ok- Severity
- warn
- Since
- 1.57.0
This is probably a copy & paste error. If arm bodies are the same on purpose, you can factor them using |. Clippy puts this lint in the pedantic group, at the level allow.
- Code
match_same_arms- Severity
- allow
Readability and needless complexity. Clippy puts this lint in the complexity group, at the level warn.
- Code
match_single_binding- Severity
- warn
- Since
- 1.43.0
The arm is unreachable, which is likely a mistake Clippy puts this lint in the correctness group, at the level deny.
- Code
match_str_case_mismatch- Severity
- deny
- Since
- 1.58.0
It is generally a bad practice, similar to catching all exceptions in java with catch(Exception) Clippy puts this lint in the pedantic group, at the level allow.
- Code
match_wild_err_arm- Severity
- allow
New enum variants added by library updates can be missed. Clippy puts this lint in the pedantic group, at the level allow.
- Code
match_wildcard_for_single_variants- Severity
- allow
- Since
- 1.45.0
While there may be places where this is acceptable (e.g., in event streams), in most cases this is simply an error. Clippy puts this lint in the pedantic group, at the level allow.
- Code
maybe_infinite_iter- Severity
- allow
std::mem::forget(t) prevents t from running its destructor, possibly causing leaks. It is not possible to detect all means of creating leaks, but it may be desirable to prohibit the simple ones. Clippy puts this lint in the restriction group, at the level allow.
- Code
mem_forget- Severity
- allow
Option already has the method take() for taking its current value (Some(..) or None) and replacing it with None. Clippy puts this lint in the style group, at the level warn.
- Code
mem_replace_option_with_none- Severity
- warn
- Since
- 1.31.0