@@ -92,12 +92,12 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
9292 mir:: BorrowKind :: Mut { .. } => "mut " ,
9393 } ;
9494 let region = self . region . to_string ( ) ;
95- let region = if region. len ( ) > 0 {
96- format ! ( "{} " , region )
95+ let separator = if ! region. is_empty ( ) {
96+ " "
9797 } else {
98- region
98+ ""
9999 } ;
100- write ! ( w, "&{}{}{:?}" , region, kind, self . borrowed_place)
100+ write ! ( w, "&{}{}{}{ :?}" , region, separator , kind, self . borrowed_place)
101101 }
102102}
103103
@@ -244,7 +244,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
244244 K : Clone + Eq + Hash ,
245245 V : Eq + Hash ,
246246 {
247- map. entry ( k. clone ( ) ) . or_insert ( FxHashSet ( ) ) . insert ( v) ;
247+ map. entry ( k. clone ( ) ) . or_default ( ) . insert ( v) ;
248248 }
249249 }
250250
@@ -261,57 +261,53 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
261261 // ... check whether we (earlier) saw a 2-phase borrow like
262262 //
263263 // TMP = &mut place
264- match self . pending_activations . get ( temp) {
265- Some ( & borrow_index) => {
266- let borrow_data = & mut self . idx_vec [ borrow_index] ;
267-
268- // Watch out: the use of TMP in the borrow itself
269- // doesn't count as an activation. =)
270- if borrow_data. reserve_location == location && context == PlaceContext :: Store {
271- return ;
272- }
264+ if let Some ( & borrow_index) = self . pending_activations . get ( temp) {
265+ let borrow_data = & mut self . idx_vec [ borrow_index] ;
273266
274- if let TwoPhaseActivation :: ActivatedAt ( other_location) =
275- borrow_data. activation_location {
276- span_bug ! (
277- self . mir. source_info( location) . span,
278- "found two uses for 2-phase borrow temporary {:?}: \
279- {:?} and {:?}",
280- temp,
281- location,
282- other_location,
283- ) ;
284- }
267+ // Watch out: the use of TMP in the borrow itself
268+ // doesn't count as an activation. =)
269+ if borrow_data. reserve_location == location && context == PlaceContext :: Store {
270+ return ;
271+ }
285272
286- // Otherwise, this is the unique later use
287- // that we expect.
288- borrow_data. activation_location = match context {
289- // The use of TMP in a shared borrow does not
290- // count as an actual activation.
291- PlaceContext :: Borrow { kind : mir:: BorrowKind :: Shared , .. }
292- | PlaceContext :: Borrow { kind : mir:: BorrowKind :: Shallow , .. } => {
293- TwoPhaseActivation :: NotActivated
294- }
295- _ => {
296- // Double check: This borrow is indeed a two-phase borrow (that is,
297- // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
298- // we've not found any other activations (checked above).
299- assert_eq ! (
300- borrow_data. activation_location,
301- TwoPhaseActivation :: NotActivated ,
302- "never found an activation for this borrow!" ,
303- ) ;
304-
305- self . activation_map
306- . entry ( location)
307- . or_default ( )
308- . push ( borrow_index) ;
309- TwoPhaseActivation :: ActivatedAt ( location)
310- }
311- } ;
273+ if let TwoPhaseActivation :: ActivatedAt ( other_location) =
274+ borrow_data. activation_location {
275+ span_bug ! (
276+ self . mir. source_info( location) . span,
277+ "found two uses for 2-phase borrow temporary {:?}: \
278+ {:?} and {:?}",
279+ temp,
280+ location,
281+ other_location,
282+ ) ;
312283 }
313284
314- None => { }
285+ // Otherwise, this is the unique later use
286+ // that we expect.
287+ borrow_data. activation_location = match context {
288+ // The use of TMP in a shared borrow does not
289+ // count as an actual activation.
290+ PlaceContext :: Borrow { kind : mir:: BorrowKind :: Shared , .. }
291+ | PlaceContext :: Borrow { kind : mir:: BorrowKind :: Shallow , .. } => {
292+ TwoPhaseActivation :: NotActivated
293+ }
294+ _ => {
295+ // Double check: This borrow is indeed a two-phase borrow (that is,
296+ // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and
297+ // we've not found any other activations (checked above).
298+ assert_eq ! (
299+ borrow_data. activation_location,
300+ TwoPhaseActivation :: NotActivated ,
301+ "never found an activation for this borrow!" ,
302+ ) ;
303+
304+ self . activation_map
305+ . entry ( location)
306+ . or_default ( )
307+ . push ( borrow_index) ;
308+ TwoPhaseActivation :: ActivatedAt ( location)
309+ }
310+ } ;
315311 }
316312 }
317313 }
0 commit comments