@@ -151,29 +151,34 @@ impl<'a, 'tcx> PointerFinder<'a, 'tcx> {
151
151
fn into_found_pointers ( self ) -> Vec < ( Place < ' tcx > , Ty < ' tcx > ) > {
152
152
self . pointers
153
153
}
154
- }
155
154
156
- impl < ' a , ' tcx > Visitor < ' tcx > for PointerFinder < ' a , ' tcx > {
157
- fn visit_place ( & mut self , place : & Place < ' tcx > , context : PlaceContext , location : Location ) {
155
+ /// Whether or not we should visit a [Place] with [PlaceContext].
156
+ ///
157
+ /// We generally only visit Reads/Writes to a place and only Borrows if
158
+ /// requested.
159
+ fn should_visit_place ( & self , context : PlaceContext ) -> bool {
158
160
match context {
159
161
PlaceContext :: MutatingUse (
160
162
MutatingUseContext :: Store
161
163
| MutatingUseContext :: Call
162
164
| MutatingUseContext :: Yield
163
165
| MutatingUseContext :: Drop ,
164
- ) => { }
166
+ ) => true ,
165
167
PlaceContext :: NonMutatingUse (
166
168
NonMutatingUseContext :: Copy | NonMutatingUseContext :: Move ,
167
- ) => { }
169
+ ) => true ,
168
170
PlaceContext :: MutatingUse ( MutatingUseContext :: Borrow )
169
- | PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow )
170
- if matches ! ( self . borrow_check_mode, BorrowCheckMode :: IncludeBorrows ) => { }
171
- _ => {
172
- return ;
171
+ | PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow ) => {
172
+ matches ! ( self . borrow_check_mode, BorrowCheckMode :: IncludeBorrows )
173
173
}
174
+ _ => false ,
174
175
}
176
+ }
177
+ }
175
178
176
- if !place. is_indirect ( ) {
179
+ impl < ' a , ' tcx > Visitor < ' tcx > for PointerFinder < ' a , ' tcx > {
180
+ fn visit_place ( & mut self , place : & Place < ' tcx > , context : PlaceContext , location : Location ) {
181
+ if !self . should_visit_place ( context) && !place. is_indirect ( ) {
177
182
return ;
178
183
}
179
184
0 commit comments