Skip to content

Commit 845a3a0

Browse files
nahuakangY-Nak
authored andcommitted
Include loops.rs changes from PR#6698
1 parent 2229a08 commit 845a3a0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clippy_lints/src/loops/for_kv_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub(super) fn check_for_loop_over_map_kv<'tcx>(
2020
let arg_span = arg.span;
2121
let (new_pat_span, kind, ty, mutbl) = match *cx.typeck_results().expr_ty(arg).kind() {
2222
ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) {
23-
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
24-
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, Mutability::Not),
23+
(key, _) if pat_is_wild(cx, key, body) => (pat[1].span, "value", ty, mutbl),
24+
(_, value) if pat_is_wild(cx, value, body) => (pat[0].span, "key", ty, Mutability::Not),
2525
_ => return,
2626
},
2727
_ => return,
@@ -59,11 +59,11 @@ pub(super) fn check_for_loop_over_map_kv<'tcx>(
5959
}
6060

6161
/// Returns `true` if the pattern is a `PatWild` or an ident prefixed with `_`.
62-
fn pat_is_wild<'tcx>(pat: &'tcx PatKind<'_>, body: &'tcx Expr<'_>) -> bool {
62+
fn pat_is_wild<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx PatKind<'_>, body: &'tcx Expr<'_>) -> bool {
6363
match *pat {
6464
PatKind::Wild => true,
6565
PatKind::Binding(_, id, ident, None) if ident.as_str().starts_with('_') => {
66-
!LocalUsedVisitor::new(id).check_expr(body)
66+
!LocalUsedVisitor::new(cx, id).check_expr(body)
6767
},
6868
_ => false,
6969
}

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
257257
then {
258258
let index_used_directly = path_to_local_id(idx, self.var);
259259
let indexed_indirectly = {
260-
let mut used_visitor = LocalUsedVisitor::new(self.var);
260+
let mut used_visitor = LocalUsedVisitor::new(self.cx, self.var);
261261
walk_expr(&mut used_visitor, idx);
262262
used_visitor.used
263263
};

0 commit comments

Comments
 (0)