@@ -226,7 +226,7 @@ impl<'tcx> Stack {
226
226
)
227
227
}
228
228
229
- /// Find the first write-incompatible item above the given one --
229
+ /// Find the first write-incompatible item above the given one --
230
230
/// i.e, find the height to which the stack will be truncated when writing to `granting`.
231
231
fn find_first_write_incompaible ( & self , granting : usize ) -> usize {
232
232
let perm = self . borrows [ granting] . perm ;
@@ -297,8 +297,7 @@ impl<'tcx> Stack {
297
297
// Remove everything above the write-compatible items, like a proper stack. This makes sure read-only and unique
298
298
// pointers become invalid on write accesses (ensures F2a, and ensures U2 for write accesses).
299
299
let first_incompatible_idx = self . find_first_write_incompaible ( granting_idx) ;
300
- while self . borrows . len ( ) > first_incompatible_idx {
301
- let item = self . borrows . pop ( ) . unwrap ( ) ;
300
+ for item in self . borrows . drain ( first_incompatible_idx..) . rev ( ) {
302
301
trace ! ( "access: popping item {}" , item) ;
303
302
Stack :: check_protector ( & item, Some ( tag) , global) ?;
304
303
}
@@ -340,8 +339,7 @@ impl<'tcx> Stack {
340
339
) ) ) ?;
341
340
342
341
// Step 2: Remove all items. Also checks for protectors.
343
- while self . borrows . len ( ) > 0 {
344
- let item = self . borrows . pop ( ) . unwrap ( ) ;
342
+ for item in self . borrows . drain ( ..) . rev ( ) {
345
343
Stack :: check_protector ( & item, None , global) ?;
346
344
}
347
345
0 commit comments