@@ -45,8 +45,8 @@ declare_lint_pass!(IfLetMutex => [IF_LET_MUTEX]);
45
45
46
46
impl < ' tcx > LateLintPass < ' tcx > for IfLetMutex {
47
47
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
48
- let mut arm_visit = ArmVisitor { cx } ;
49
- let mut op_visit = OppVisitor { cx } ;
48
+ let mut arm_visit = MutexVisitor { cx } ;
49
+ let mut op_visit = MutexVisitor { cx } ;
50
50
if let Some ( higher:: IfLet {
51
51
let_expr,
52
52
if_then,
@@ -87,11 +87,11 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex {
87
87
}
88
88
89
89
/// Checks if `Mutex::lock` is called in the `if let` expr.
90
- pub struct OppVisitor < ' a , ' tcx > {
90
+ pub struct MutexVisitor < ' a , ' tcx > {
91
91
cx : & ' a LateContext < ' tcx > ,
92
92
}
93
93
94
- impl < ' tcx > Visitor < ' tcx > for OppVisitor < ' _ , ' tcx > {
94
+ impl < ' tcx > Visitor < ' tcx > for MutexVisitor < ' _ , ' tcx > {
95
95
type Result = ControlFlow < & ' tcx Expr < ' tcx > > ;
96
96
fn visit_expr ( & mut self , expr : & ' tcx Expr < ' _ > ) -> ControlFlow < & ' tcx Expr < ' tcx > > {
97
97
if let Some ( mutex) = is_mutex_lock_call ( self . cx , expr) {
@@ -101,22 +101,7 @@ impl<'tcx> Visitor<'tcx> for OppVisitor<'_, 'tcx> {
101
101
}
102
102
}
103
103
104
- /// Checks if `Mutex::lock` is called in any of the branches.
105
- pub struct ArmVisitor < ' a , ' tcx > {
106
- cx : & ' a LateContext < ' tcx > ,
107
- }
108
-
109
- impl < ' tcx > Visitor < ' tcx > for ArmVisitor < ' _ , ' tcx > {
110
- type Result = ControlFlow < & ' tcx Expr < ' tcx > > ;
111
- fn visit_expr ( & mut self , expr : & ' tcx Expr < ' tcx > ) -> ControlFlow < & ' tcx Expr < ' tcx > > {
112
- if let Some ( mutex) = is_mutex_lock_call ( self . cx , expr) {
113
- return ControlFlow :: Break ( mutex) ;
114
- }
115
- visit:: walk_expr ( self , expr)
116
- }
117
- }
118
-
119
- impl < ' tcx , ' l > ArmVisitor < ' tcx , ' l > {
104
+ impl < ' tcx , ' l > MutexVisitor < ' tcx , ' l > {
120
105
fn found_mutex_if_same_as ( & self , op_mutex : & Expr < ' _ > , found_mutex : Option < & ' tcx Expr < ' tcx > > ) -> Option < & Expr < ' _ > > {
121
106
found_mutex. and_then ( |arm_mutex| {
122
107
SpanlessEq :: new ( self . cx )
0 commit comments