Fix invalid while_let_on_iterator suggestion#3784
Fix invalid while_let_on_iterator suggestion#3784jfirebaugh wants to merge 3 commits intorust-lang:masterfrom
Conversation
Slice patterns without .. are refutable.
clippy_lints/src/utils/mod.rs
Outdated
| PatKind::Slice(ref head, ref middle, ref tail) => { | ||
| are_refutable(cx, head.iter().chain(middle).chain(tail.iter()).map(|pat| &**pat)) | ||
| if middle.is_none() { | ||
| true |
There was a problem hiding this comment.
It might still be irrefutable if head or tail are irrefutable
There was a problem hiding this comment.
Are you referring to matches on array types? As @mikerite points out, the only irrefutable slice pattern on slices is [..].
Not sure, but we can probably pass in the relevant information |
|
The patterns |
It appears so; I've added type-checking in the latest commit, though I am not too sure of its correctness. I see that MIR handles the case where the pattern is As an aside, it would be nice to lean on the compiler for something like |
|
☔ The latest upstream changes (presumably #3803) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Ping @jfirebaugh. I'm going over old PRs, that were abandoned by us reviewers (sorry for that!) or by the authors. Are you still interested in completing this? |
|
Ping from triage @jfirebaugh. Sorry for neglecting this PR and thanks for your contribution. If you want to continue working on this, feel free to reopen and ping me. I'll be happy to help you wrapping this up. |
Slice patterns without
..are refutable. (Well, except if the match source is an array type -- doesis_refutablehave enough information to check this though?)Fixes #3780.