Skip to content

Commit 85490d1

Browse files
committed
clean-up
1 parent ebbbbeb commit 85490d1

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

clippy_lints/src/mutex_atomic.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,17 @@ impl<'tcx> LateLintPass<'tcx> for Mutex {
9393
let ty = cx.typeck_results().expr_ty(expr);
9494
if let ty::Adt(_, subst) = ty.kind()
9595
&& ty.is_diag_item(cx, sym::Mutex)
96+
&& let mutex_param = subst.type_at(0)
97+
&& let Some(atomic_name) = get_atomic_name(mutex_param)
9698
{
97-
let mutex_param = subst.type_at(0);
98-
if let Some(atomic_name) = get_atomic_name(mutex_param) {
99-
let msg = format!(
100-
"consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \
101-
behavior and not the internal type, consider using `Mutex<()>`"
102-
);
103-
match *mutex_param.kind() {
104-
ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
105-
ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
106-
_ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg),
107-
}
99+
let msg = format!(
100+
"consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \
101+
behavior and not the internal type, consider using `Mutex<()>`"
102+
);
103+
match *mutex_param.kind() {
104+
ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
105+
ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
106+
_ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg),
108107
}
109108
}
110109
}

0 commit comments

Comments
 (0)