@@ -230,68 +230,68 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
230230 self . super_assign ( block, assigned_place, rvalue, location)
231231 }
232232
233- fn visit_place (
233+ fn visit_local (
234234 & mut self ,
235- place : & mir :: Place < ' tcx > ,
235+ temp : & Local ,
236236 context : PlaceContext < ' tcx > ,
237237 location : Location ,
238238 ) {
239- self . super_place ( place, context, location) ;
240-
241- // We found a use of some temporary TEMP...
242- if let Place :: Local ( temp) = place {
243- // ... check whether we (earlier) saw a 2-phase borrow like
244- //
245- // TMP = &mut place
246- if let Some ( & borrow_index) = self . pending_activations . get ( temp) {
247- let borrow_data = & mut self . idx_vec [ borrow_index] ;
248-
249- // Watch out: the use of TMP in the borrow itself
250- // doesn't count as an activation. =)
251- if borrow_data. reserve_location == location &&
252- context == PlaceContext :: MutatingUse ( MutatingUseContext :: Store )
253- {
254- return ;
255- }
239+ if !context. is_use ( ) {
240+ return ;
241+ }
256242
257- if let TwoPhaseActivation :: ActivatedAt ( other_location) =
258- borrow_data. activation_location {
259- span_bug ! (
260- self . mir. source_info( location) . span,
261- "found two uses for 2-phase borrow temporary {:?}: \
262- {:?} and {:?}",
263- temp,
264- location,
265- other_location,
266- ) ;
267- }
243+ // We found a use of some temporary TMP
244+ // check whether we (earlier) saw a 2-phase borrow like
245+ //
246+ // TMP = &mut place
247+ if let Some ( & borrow_index) = self . pending_activations . get ( temp) {
248+ let borrow_data = & mut self . idx_vec [ borrow_index] ;
268249
269- // Otherwise, this is the unique later use
270- // that we expect.
271- borrow_data. activation_location = match context {
272- // The use of TMP in a shared borrow does not
273- // count as an actual activation.
274- PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow ( ..) ) |
275- PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: ShallowBorrow ( ..) ) =>
276- TwoPhaseActivation :: NotActivated ,
277- _ => {
278- // Double check: This borrow is indeed a two-phase borrow (that is,
279- // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
280- // we've not found any other activations (checked above).
281- assert_eq ! (
282- borrow_data. activation_location,
283- TwoPhaseActivation :: NotActivated ,
284- "never found an activation for this borrow!" ,
285- ) ;
286-
287- self . activation_map
288- . entry ( location)
289- . or_default ( )
290- . push ( borrow_index) ;
291- TwoPhaseActivation :: ActivatedAt ( location)
292- }
293- } ;
250+ // Watch out: the use of TMP in the borrow itself
251+ // doesn't count as an activation. =)
252+ if borrow_data. reserve_location == location &&
253+ context == PlaceContext :: MutatingUse ( MutatingUseContext :: Store )
254+ {
255+ return ;
294256 }
257+
258+ if let TwoPhaseActivation :: ActivatedAt ( other_location) =
259+ borrow_data. activation_location {
260+ span_bug ! (
261+ self . mir. source_info( location) . span,
262+ "found two uses for 2-phase borrow temporary {:?}: \
263+ {:?} and {:?}",
264+ temp,
265+ location,
266+ other_location,
267+ ) ;
268+ }
269+
270+ // Otherwise, this is the unique later use
271+ // that we expect.
272+ borrow_data. activation_location = match context {
273+ // The use of TMP in a shared borrow does not
274+ // count as an actual activation.
275+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: SharedBorrow ( ..) ) |
276+ PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: ShallowBorrow ( ..) ) =>
277+ TwoPhaseActivation :: NotActivated ,
278+ _ => {
279+ // Double check: This borrow is indeed a two-phase borrow (that is,
280+ // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
281+ // we've not found any other activations (checked above).
282+ assert_eq ! (
283+ borrow_data. activation_location,
284+ TwoPhaseActivation :: NotActivated ,
285+ "never found an activation for this borrow!" ,
286+ ) ;
287+
288+ self . activation_map
289+ . entry ( location)
290+ . or_default ( )
291+ . push ( borrow_index) ;
292+ TwoPhaseActivation :: ActivatedAt ( location)
293+ }
294+ } ;
295295 }
296296 }
297297
0 commit comments