Skip to content

Commit 759ee18

Browse files
committed
fix: _return_ when doesn't impl {index/deref}_mut
1 parent 640be36 commit 759ee18

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

clippy_lints/src/methods/mut_mutex_lock.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, name_s
3838
loop {
3939
match r.kind {
4040
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-
{
44-
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+
}
4547
},
46-
// `base` here can't actually have adjustments
47-
ExprKind::Unary(UnOp::Deref, base) if impls_deref_mut(typeck.expr_ty_adjusted(base)) => {
48-
r = base;
49-
continue;
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+
}
5056
},
5157
_ => break 'outer,
5258
}

0 commit comments

Comments
 (0)