Rust lints, page 5 of 5
The lint rules of Rust, with what each one finds. This page has 844 cards.
In CamelCase, acronyms count as one word. See naming conventions for more. Clippy puts this lint in the style group, at the level warn.
- Code
upper_case_acronyms- Severity
- warn
- Since
- 1.51.0
The purpose of this lint is to catch debugging remnants. The purpose of the Debug trait is to facilitate debugging Rust code, and no guarantees are made about its output. It should not be used in user-facing output. Clippy puts this lint in the restriction group, at the level allow.
- Code
use_debug- Severity
- allow
Unnecessary repetition. Mixed use of Self and struct name feels inconsistent. Clippy puts this lint in the nursery group, at the level allow.
- Code
use_self- Severity
- allow
A single leading underscore is usually used to indicate that a binding will not be used. Using such a binding breaks this expectation. Clippy puts this lint in the pedantic group, at the level allow.
- Code
used_underscore_binding- Severity
- allow
A single leading underscore is usually used to indicate that a item will not be used. Using such a item breaks this expectation. Clippy puts this lint in the pedantic group, at the level allow.
- Code
used_underscore_items- Severity
- allow
- Since
- 1.83.0
The call is unnecessary. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_asref- Severity
- warn
Lint attributes have no effect on crate imports. Most likely a ! was forgotten. Clippy puts this lint in the correctness group, at the level deny.
- Code
useless_attribute- Severity
- deny
The extra & is redundant and can make the code less clear. Format macros take references to the arguments internally, so passing &x when x is already a reference produces a double reference. The compiler is currently unable to optimize double references, which results in about 6% degradation per call. Clippy puts this lint in the perf group, at the level warn.
- Code
useless_borrows_in_formatting- Severity
- warn
- Since
- 1.97.0
If there are less than 2 arguments, then calling the macro is doing nothing. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_concat- Severity
- warn
- Since
- 1.89.0
Redundant code. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_conversion- Severity
- warn
- Since
- 1.45.0
There is no point of doing that. format!("foo") can be replaced by "foo".to_owned() if you really need a String. The even worse &format!("foo") is often encountered in the wild. format!("{}", foo) can be replaced by foo.clone() if foo: String or foo.to_owned() if foo: &str. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_format- Severity
- warn
This is not idiomatic Rust. Clippy puts this lint in the nursery group, at the level allow.
- Code
useless_let_if_seq- Severity
- allow
Using NonZero*::new_unchecked() is an unsafe function and requires an unsafe context. When used in a context evaluated at compilation time, NonZero*::new().unwrap() will provide the same result with identical runtime performances while not requiring unsafe. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_nonzero_new_unchecked- Severity
- warn
- Since
- 1.86.0
Readability. The code tricks people into thinking that something complex is going on. Clippy puts this lint in the complexity group, at the level warn.
- Code
useless_transmute- Severity
- warn
This is less efficient. Clippy puts this lint in the perf group, at the level warn.
- Code
useless_vec- Severity
- warn
Sized anywhere in the code. Check the Box documentation for more information. Vec already keeps its contents in a separate area on the heap. So if you Box its contents, you just add another level of indirection. Clippy puts this lint in the complexity group, at the level warn.
- Code
vec_box- Severity
- warn
- Since
- 1.33.0
The vec![] macro is both more performant and easier to read than multiple push calls. Clippy puts this lint in the perf group, at the level warn.
- Code
vec_init_then_push- Severity
- warn
- Since
- 1.51.0
This is probably an argument inversion mistake. Clippy puts this lint in the correctness group, at the level deny.
- Code
vec_resize_to_zero- Severity
- deny
- Since
- 1.46.0
x.trailing_zeros() >= 4 is much clearer than x & 15 == 0 Clippy puts this lint in the pedantic group, at the level allow.
- Code
verbose_bit_mask- Severity
- allow
fs::{read, read_to_string} provide the same functionality when buf is empty with fewer imports and no intermediate values. See also: fs::read docs, fs::read_to_string docs Clippy puts this lint in the restriction group, at the level allow.
- Code
verbose_file_reads- Severity
- allow
- Since
- 1.44.0
Volatile operations are typically used with memory mapped IO devices, where the precise number and ordering of load and store instructions is important because they can have side effects. This is well defined for primitive types like u32, but less well defined for structures and other composite types. In practice it’s implementation defined, and the behavior can be rustc-version dependent. Clippy puts this lint in the nursery group, at the level allow.
- Code
volatile_composites- Severity
- allow
- Since
- 1.92.0
Cloning the waker is not necessary, wake_by_ref() enables the same operation without extra cloning/dropping. Clippy puts this lint in the perf group, at the level warn.
- Code
waker_clone_wake- Severity
- warn
- Since
- 1.75.0
If you increment floating point values, errors can compound, so, use integers instead if possible. Clippy puts this lint in the nursery group, at the level allow.
- Code
while_float- Severity
- allow
- Since
- 1.80.0
If the condition is unchanged, entering the body of the loop will lead to an infinite loop. Clippy puts this lint in the correctness group, at the level deny.
- Code
while_immutable_condition- Severity
- deny
The while let loop is usually shorter and more readable. Clippy puts this lint in the complexity group, at the level warn.
- Code
while_let_loop- Severity
- warn
Readability. A simple for loop is shorter and conveys the intent better. Clippy puts this lint in the style group, at the level warn.
- Code
while_let_on_iterator- Severity
- warn
As the edition guide says, it is highly unlikely that you work with any possible version of your dependency, and wildcard dependencies would cause unnecessary breakage in the ecosystem. Clippy puts this lint in the cargo group, at the level allow.
- Code
wildcard_dependencies- Severity
- allow
- Since
- 1.32.0
New enum variants added by library updates can be missed. Clippy puts this lint in the restriction group, at the level allow.
- Code
wildcard_enum_match_arm- Severity
- allow
- Since
- 1.34.0
wildcard imports can pollute the namespace. This is especially bad if you try to import something through a wildcard, that already has been imported by name from a different source: Clippy puts this lint in the pedantic group, at the level allow.
- Code
wildcard_imports- Severity
- allow
- Since
- 1.43.0
Wildcard pattern already covers any other pattern as it will match anyway. It makes the code less readable, especially to spot wildcard pattern use in match arm. Clippy puts this lint in the complexity group, at the level warn.
- Code
wildcard_in_or_patterns- Severity
- warn
- Since
- 1.42.0
Calling with_capacity(0) does not allocate any initial capacity and behaves identically to new(). Using new() is more idiomatic, concise, and is a const fn for these types. Clippy puts this lint in the pedantic group, at the level allow.
- Code
with_capacity_zero- Severity
- allow
- Since
- 1.98.0
Using literals as writeln! args is inefficient (c.f., https://github.com/matthiaskrgr/rust-str-bench) and unnecessary (i.e., just put the literal in the format string) Clippy puts this lint in the style group, at the level warn.
- Code
write_literal- Severity
- warn
You should use writeln!() instead, which appends the newline. Clippy puts this lint in the style group, at the level warn.
- Code
write_with_newline- Severity
- warn
You should use writeln!(buf), which is simpler. Clippy puts this lint in the style group, at the level warn.
- Code
writeln_empty_string- Severity
- warn
Nothing. wrong_pub_self_convention
This lint has been deprecated Clippy puts this lint in the deprecated group, at the level none.
- Code
wrong_pub_self_convention- Severity
- none
- Since
- 1.54.0
The actual rules are: Consistency breeds readability. If you follow the conventions, your users won’t be surprised that they, e.g., need to supply a mutable reference to a as_.. function. Clippy puts this lint in the style group, at the level warn.
- Code
wrong_self_convention- Severity
- warn
It’s basically guaranteed to be undefined behavior. Clippy puts this lint in the correctness group, at the level deny.
- Code
wrong_transmute- Severity
- deny
It’s less readable than f32::NAN or f64::NAN. Clippy puts this lint in the complexity group, at the level warn.
- Code
zero_divided_by_zero- Severity
- warn
In some languages (including the infamous C language and most of its family), this marks an octal constant. In Rust however, this is a decimal constant. This could be confusing for both the writer and a reader of the constant. Clippy puts this lint in the complexity group, at the level warn.
- Code
zero_prefixed_literal- Severity
- warn
This generally means null and is better expressed as {std, core}::ptr::{null, null_mut}. Clippy puts this lint in the style group, at the level warn.
- Code
zero_ptr- Severity
- warn
Such an initialization, despite having a repeat length of 0, will still call the inner function. This may not be obvious and as such there may be unintended side effects in code. Clippy puts this lint in the suspicious group, at the level warn.
- Code
zero_repeat_side_effects- Severity
- warn
- Since
- 1.79.0
Since there is only a single value for a zero-sized type, a map containing zero sized values is effectively a set. Using a set in that case improves readability and communicates intent more clearly. Clippy puts this lint in the pedantic group, at the level allow.
- Code
zero_sized_map_values- Severity
- allow
- Since
- 1.50.0
As explained in the standard library documentation, calling wait() is necessary on Unix platforms to properly release all OS resources associated with the process. Not doing so will effectively leak process IDs and/or other limited global resources, which can eventually lead to resource exhaustion, so it’s recommended to call wait() in long-running applications. Such processes are called “zombie processes”. Clippy puts this lint in the suspicious group, at the level warn.
- Code
zombie_processes- Severity
- warn
- Since
- 1.83.0
This is a no-op, and likely unintended Clippy puts this lint in the correctness group, at the level deny.
- Code
zst_offset- Severity
- deny
- Since
- 1.41.0