
Description
The nightly slice_patterns
feature (see https://doc.rust-lang.org/nightly/unstable-book/language-features/slice-patterns.html) introduces the syntax ..
which matches any leftover elements in the slice, versus the _
for a single item in stable Rust.
Clippy's redundant_pattern
lint checks for variable @ _
and correctly recommends it be changed to plain variable
. However, there is (currently) no shorter syntax for variable @ ..
in patterns, and the recommendation to change it to variable
is incorrect and changes the meaning. There is also a cosmetic error in that it gives the binding as _
rather than ..
.
I am using the latest nightly clippy ("clippy 0.0.212 (cd3df6b 2019-08-20)") and this is one example of the cascade of warnings it gives when choking on my parser library:
warning: the `stream @ _` pattern can be written as just `stream`
--> src/bencode.rs:321:20
|
321 | [b'l', stream @ ..] => decode_list(stream).map(wrap),
| ^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
(In case it's not obvious, this is within a match { ... }
block.)
The desired behaviour is for Clippy is to not treat ..
as equivalent to _
in patterns, because it isn't. Perhaps it was at some point in the evolution of this feature, but it isn't now.