Skip to content

Commit 6741794

Browse files
committed
Detect all variants of stack removals
1 parent a0de213 commit 6741794

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/stacked_borrows.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ impl<'tcx> Stack {
271271

272272
/// Check if the given item is protected.
273273
fn check_protector(item: &Item, tag: Option<Tag>, global: &GlobalState) -> InterpResult<'tcx> {
274+
if let Tag::Tagged(id) = item.tag {
275+
if Some(id) == global.tracked_id {
276+
throw_unsup!(Unsupported(format!("disabling item {:?} for tag {:?}", item, tag)));
277+
}
278+
}
274279
if let Some(call) = item.protector {
275280
if global.is_active(call) {
276281
if let Some(tag) = tag {
@@ -313,11 +318,6 @@ impl<'tcx> Stack {
313318
let first_incompatible_idx = self.find_first_write_incompatible(granting_idx);
314319
for item in self.borrows.drain(first_incompatible_idx..).rev() {
315320
trace!("access: popping item {:?}", item);
316-
if let Tag::Tagged(id) = item.tag {
317-
if Some(id) == global.tracked_id {
318-
throw_unsup!(Unsupported(format!("popped id {}", id)));
319-
}
320-
}
321321
Stack::check_protector(&item, Some(tag), global)?;
322322
}
323323
} else {

tests/compile-fail/stacked_borrows/track_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313
let reference = unsafe { &*raw }; // freeze
1414
let ptr = reference as *const _ as *mut i32; // raw ptr, with raw tag
1515
let _mut_ref: &mut i32 = unsafe { mem::transmute(ptr) }; // &mut, with raw tag
16-
//~^ ERROR popped id 1372
16+
//~^ ERROR disabling item [SharedReadOnly for <1372>] for tag Some(<untagged>)
1717
// Now we retag, making our ref top-of-stack -- and, in particular, unfreezing.
1818
let _val = *reference;
1919
}

0 commit comments

Comments
 (0)