We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
unused_enumerate_index
1 parent 902c79c commit 294df80Copy full SHA for 294df80
clippy_lints/src/loops/unused_enumerate_index.rs
@@ -9,7 +9,7 @@ use rustc_middle::ty;
9
10
/// Checks for the `UNUSED_ENUMERATE_INDEX` lint.
11
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx Expr<'_>, body: &'tcx Expr<'_>) {
12
- let PatKind::Tuple(tuple, _) = pat.kind else {
+ let PatKind::Tuple([index, elem], _) = pat.kind else {
13
return;
14
};
15
@@ -19,7 +19,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx
19
20
let ty = cx.typeck_results().expr_ty(arg);
21
22
- if !pat_is_wild(cx, &tuple[0].kind, body) {
+ if !pat_is_wild(cx, &index.kind, body) {
23
24
}
25
@@ -53,7 +53,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx
53
diag,
54
"remove the `.enumerate()` call",
55
vec![
56
- (pat.span, snippet(cx, tuple[1].span, "..").into_owned()),
+ (pat.span, snippet(cx, elem.span, "..").into_owned()),
57
(arg.span, base_iter.to_string()),
58
],
59
);
tests/ui/crashes/ice-11755.rs
@@ -0,0 +1,5 @@
1
+#![warn(clippy::unused_enumerate_index)]
2
+
3
+fn main() {
4
+ for () in [()].iter() {}
5
+}
0 commit comments