clean-up
This commit is contained in:
parent
ebbbbebf2d
commit
85490d1845
1 changed files with 10 additions and 11 deletions
|
|
@ -93,18 +93,17 @@ impl<'tcx> LateLintPass<'tcx> for Mutex {
|
|||
let ty = cx.typeck_results().expr_ty(expr);
|
||||
if let ty::Adt(_, subst) = ty.kind()
|
||||
&& ty.is_diag_item(cx, sym::Mutex)
|
||||
&& let mutex_param = subst.type_at(0)
|
||||
&& let Some(atomic_name) = get_atomic_name(mutex_param)
|
||||
{
|
||||
let mutex_param = subst.type_at(0);
|
||||
if let Some(atomic_name) = get_atomic_name(mutex_param) {
|
||||
let msg = format!(
|
||||
"consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \
|
||||
behavior and not the internal type, consider using `Mutex<()>`"
|
||||
);
|
||||
match *mutex_param.kind() {
|
||||
ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
|
||||
ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
|
||||
_ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg),
|
||||
}
|
||||
let msg = format!(
|
||||
"consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \
|
||||
behavior and not the internal type, consider using `Mutex<()>`"
|
||||
);
|
||||
match *mutex_param.kind() {
|
||||
ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
|
||||
ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg),
|
||||
_ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue