RS.CLIPPY.UNNEEDED_WILDCARD_PATTERN
Tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unneeded_wildcard_pattern. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for tuple patterns with a wildcard
pattern (_) is next to a rest pattern (..).
NOTE: While _, .. means there is at least one element left, ..
means there are 0 or more elements left. This can make a difference
when refactoring, but shouldn't result in errors in the refactored code,
since the wildcard pattern isn't used anyway.
Why is this bad?
The wildcard pattern is unneeded as the rest pattern can match that element as well.
Example
match t {
TupleStruct(0, .., _) => (),
_ => (),
}
Use instead:
match t {
TupleStruct(0, ..) => (),
_ => (),
}