@@ -245,40 +245,31 @@ impl<'tcx> Stack {
245
245
fn create ( & mut self , bor : Borrow , kind : RefKind ) {
246
246
// First, push the item. We do this even if we will later freeze, because we
247
247
// will allow mutation of shared data at the expense of unfreezing.
248
- if let Some ( itm_t) = self . frozen_since {
249
- // A frozen location, we won't change anything here!
250
- match bor {
251
- Borrow :: Uniq ( _) => bug ! ( "Trying to create unique ref to frozen location" ) ,
252
- Borrow :: Shr ( Some ( bor_t) ) if kind == RefKind :: Frozen => {
253
- // Make sure we are frozen long enough. This is part 1 of ensuring F1.
254
- assert ! ( itm_t <= bor_t, "Trying to freeze shorter than it was frozen?" ) ;
255
- trace ! ( "create: Freezing a frozen location is a NOP" ) ;
256
- }
257
- Borrow :: Shr ( _) => trace ! ( "create: Sharing a frozen location is a NOP" ) ,
258
- }
248
+ if self . frozen_since . is_some ( ) {
249
+ // A frozen location, this should be impossible!
250
+ bug ! ( "We should never try pushing to a frozen stack" ) ;
251
+ }
252
+ // First, push.
253
+ let itm = match bor {
254
+ Borrow :: Uniq ( t) => BorStackItem :: Uniq ( t) ,
255
+ Borrow :: Shr ( _) => BorStackItem :: Shr ,
256
+ } ;
257
+ if * self . borrows . last ( ) . unwrap ( ) == itm {
258
+ assert ! ( bor. is_shared( ) ) ;
259
+ trace ! ( "create: Sharing a shared location is a NOP" ) ;
259
260
} else {
260
- // First push.
261
- let itm = match bor {
262
- Borrow :: Uniq ( t) => BorStackItem :: Uniq ( t) ,
263
- Borrow :: Shr ( _) => BorStackItem :: Shr ,
261
+ // This ensures U1.
262
+ trace ! ( "create: Pushing {:?}" , itm) ;
263
+ self . borrows . push ( itm) ;
264
+ }
265
+ // Then, maybe freeze. This is part 2 of ensuring F1.
266
+ if kind == RefKind :: Frozen {
267
+ let bor_t = match bor {
268
+ Borrow :: Shr ( Some ( t) ) => t,
269
+ _ => bug ! ( "Creating illegal borrow {:?} for frozen ref" , bor) ,
264
270
} ;
265
- if * self . borrows . last ( ) . unwrap ( ) == itm {
266
- assert ! ( bor. is_shared( ) ) ;
267
- trace ! ( "create: Sharing a shared location is a NOP" ) ;
268
- } else {
269
- // This ensures U1.
270
- trace ! ( "create: Pushing {:?}" , itm) ;
271
- self . borrows . push ( itm) ;
272
- }
273
- // Now, maybe freeze. This is part 2 of ensuring F1.
274
- if kind == RefKind :: Frozen {
275
- let bor_t = match bor {
276
- Borrow :: Shr ( Some ( t) ) => t,
277
- _ => bug ! ( "Creating illegal borrow {:?} for frozen ref" , bor) ,
278
- } ;
279
- trace ! ( "create: Freezing" ) ;
280
- self . frozen_since = Some ( bor_t) ;
281
- }
271
+ trace ! ( "create: Freezing" ) ;
272
+ self . frozen_since = Some ( bor_t) ;
282
273
}
283
274
}
284
275
}
0 commit comments