@@ -65,7 +65,9 @@ fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr) -> Optio
65
65
if let ExprKind :: Unary ( UnOp :: UnNot , ref condition) = droptmp. kind;
66
66
then {
67
67
// debug_assert
68
- return MutArgVisitor :: go( cx, condition) ;
68
+ let mut visitor = MutArgVisitor :: new( cx) ;
69
+ visitor. visit_expr( condition) ;
70
+ return visitor. expr_span( ) ;
69
71
} else {
70
72
// debug_assert_{eq,ne}
71
73
if_chain! {
@@ -76,12 +78,16 @@ fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr) -> Optio
76
78
if conditions. len( ) == 2 ;
77
79
then {
78
80
if let ExprKind :: AddrOf ( _, ref lhs) = conditions[ 0 ] . kind {
79
- if let Some ( span) = MutArgVisitor :: go( cx, lhs) {
81
+ let mut visitor = MutArgVisitor :: new( cx) ;
82
+ visitor. visit_expr( lhs) ;
83
+ if let Some ( span) = visitor. expr_span( ) {
80
84
return Some ( span) ;
81
85
}
82
86
}
83
87
if let ExprKind :: AddrOf ( _, ref rhs) = conditions[ 1 ] . kind {
84
- if let Some ( span) = MutArgVisitor :: go( cx, rhs) {
88
+ let mut visitor = MutArgVisitor :: new( cx) ;
89
+ visitor. visit_expr( rhs) ;
90
+ if let Some ( span) = visitor. expr_span( ) {
85
91
return Some ( span) ;
86
92
}
87
93
}
@@ -110,19 +116,13 @@ impl<'a, 'tcx> MutArgVisitor<'a, 'tcx> {
110
116
}
111
117
}
112
118
113
- fn get_span ( & self ) -> Option < Span > {
119
+ fn expr_span ( & self ) -> Option < Span > {
114
120
if self . found {
115
121
self . expr_span
116
122
} else {
117
123
None
118
124
}
119
125
}
120
-
121
- fn go ( cx : & ' a LateContext < ' a , ' tcx > , start : & ' tcx Expr ) -> Option < Span > {
122
- let mut s = Self :: new ( cx) ;
123
- s. visit_expr ( start) ;
124
- s. get_span ( )
125
- }
126
126
}
127
127
128
128
impl < ' a , ' tcx > Visitor < ' tcx > for MutArgVisitor < ' a , ' tcx > {
@@ -150,6 +150,6 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> {
150
150
}
151
151
152
152
fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' tcx > {
153
- NestedVisitorMap :: All ( & self . cx . tcx . hir ( ) )
153
+ NestedVisitorMap :: OnlyBodies ( & self . cx . tcx . hir ( ) )
154
154
}
155
155
}
0 commit comments