2022-07-11 19:54:31 -05:00
|
|
|
//@error-pattern: deallocating while item
|
2022-06-25 18:15:11 -05:00
|
|
|
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) });
|
|
|
|
});
|
|
|
|
}
|