new lint: warn if we match on index item and use wildcard pattern #5500
Labels
A-lint
Area: New lints
good-first-issue
These issues are a good way to get started with Clippy
L-style
Lint: Belongs in the style lint group
T-AST
Type: Requires working with the AST
Inspired by #5499
In this code we can see that we match on an item in a certain vector position, we only care about a limited number of cases and ignore the rest.
This code will panic if the
idx
is out of bounds, as it is the case here.If we could lint the
pattern where nothing happens anyway if we don't find any of the matched patterns in the vector position, we could suggest using .get() and avoid the panic:
The text was updated successfully, but these errors were encountered: