Skip to content

Commit 57b8d0d

Browse files
committed
remove optimization for simpler code
since there won't be any adjustments after an explicit deref, the adjustment checking step should finish pretty fast
1 parent d72a725 commit 57b8d0d

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

clippy_lints/src/methods/mut_mutex_lock.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, name_s
2020
let impls_deref_mut = |ty| deref_mut_trait.is_some_and(|trait_id| implements_trait(cx, ty, trait_id, &[]));
2121
let impls_index_mut = |ty, idx| index_mut_trait.is_some_and(|trait_id| implements_trait(cx, ty, trait_id, &[idx]));
2222
let mut r = recv;
23-
'outer: loop {
23+
loop {
2424
if (typeck.expr_adjustments(r))
2525
.iter()
2626
.map_while(|a| match a.kind {
@@ -35,28 +35,23 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, name_s
3535
{
3636
return;
3737
}
38-
loop {
39-
match r.kind {
40-
ExprKind::Field(base, _) => r = base,
41-
ExprKind::Index(base, idx, _) => {
42-
if impls_index_mut(typeck.expr_ty_adjusted(base), typeck.expr_ty_adjusted(idx).into()) {
43-
r = base;
44-
} else {
45-
return;
46-
}
47-
},
48-
ExprKind::Unary(UnOp::Deref, base) => {
49-
if impls_deref_mut(typeck.expr_ty_adjusted(base)) {
50-
r = base;
51-
// `base` here can't actually have adjustments
52-
continue;
53-
} else {
54-
return;
55-
}
56-
},
57-
_ => break 'outer,
58-
}
59-
continue 'outer;
38+
match r.kind {
39+
ExprKind::Field(base, _) => r = base,
40+
ExprKind::Index(base, idx, _) => {
41+
if impls_index_mut(typeck.expr_ty_adjusted(base), typeck.expr_ty_adjusted(idx).into()) {
42+
r = base;
43+
} else {
44+
return;
45+
}
46+
},
47+
ExprKind::Unary(UnOp::Deref, base) => {
48+
if impls_deref_mut(typeck.expr_ty_adjusted(base)) {
49+
r = base;
50+
} else {
51+
return;
52+
}
53+
},
54+
_ => break,
6055
}
6156
}
6257

0 commit comments

Comments
 (0)