4eff60ad6e
stacked_borrow now has an item module, and its own FrameExtra. These serve to protect the implementation of Item (which is a bunch of bit-packing tricks) from the primary logic of Stacked Borrows, and the FrameExtra we have separates Stacked Borrows more cleanly from the interpreter itself. The new strategy for checking protectors also makes some subtle performance tradeoffs, so they are now documented in Stack::item_popped because that function primarily benefits from them, and it also touches every aspect of them. Also separating the actual CallId that is protecting a Tag from the Tag makes it inconvienent to reproduce exactly the same protector errors, so this also takes the opportunity to use some slightly cleaner English in those errors. We need to make some change, might as well make it good.
17 lines
393 B
Rust
17 lines
393 B
Rust
//@error-pattern: deallocating while item
|
|
use std::marker::PhantomPinned;
|
|
|
|
pub struct NotUnpin(i32, PhantomPinned);
|
|
|
|
fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
|
|
// `f` may mutate, but it may not deallocate!
|
|
f(x)
|
|
}
|
|
|
|
fn main() {
|
|
inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
|
|
let raw = x as *mut _;
|
|
drop(unsafe { Box::from_raw(raw) });
|
|
});
|
|
}
|