@@ -44,7 +44,11 @@ declare_lint_pass!(MutMutexLock => [MUT_MUTEX_LOCK]);
44
44
impl < ' tcx > LateLintPass < ' tcx > for MutMutexLock {
45
45
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , ex : & ' tcx Expr < ' tcx > ) {
46
46
if_chain ! {
47
- if is_mut_mutex_lock_call( cx, ex) . is_some( ) ;
47
+ if let ExprKind :: MethodCall ( path, _span, args, _) = & ex. kind;
48
+ if path. ident. name == sym!( lock) ;
49
+ let ty = cx. typeck_results( ) . expr_ty( & args[ 0 ] ) ;
50
+ if let ty:: Ref ( _, inner_ty, Mutability :: Mut ) = ty. kind( ) ;
51
+ if is_type_diagnostic_item( cx, inner_ty, sym!( mutex_type) ) ;
48
52
then {
49
53
span_lint_and_help(
50
54
cx,
@@ -58,18 +62,3 @@ impl<'tcx> LateLintPass<'tcx> for MutMutexLock {
58
62
}
59
63
}
60
64
}
61
-
62
- fn is_mut_mutex_lock_call < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) -> Option < & ' tcx Expr < ' tcx > > {
63
- if_chain ! {
64
- if let ExprKind :: MethodCall ( path, _span, args, _) = & expr. kind;
65
- if path. ident. name == sym!( lock) ;
66
- let ty = cx. typeck_results( ) . expr_ty( & args[ 0 ] ) ;
67
- if let ty:: Ref ( _, inner_ty, Mutability :: Mut ) = ty. kind( ) ;
68
- if is_type_diagnostic_item( cx, inner_ty, sym!( mutex_type) ) ;
69
- then {
70
- Some ( & args[ 0 ] )
71
- } else {
72
- None
73
- }
74
- }
75
- }
0 commit comments