rust/tests/compile-fail/stacked_borrows/deallocate_against_barrier1.rs
2019-08-09 19:22:47 +02:00

14 lines
297 B
Rust

// error-pattern: deallocating while item is protected
fn inner(x: &mut i32, f: fn(&mut i32)) {
// `f` may mutate, but it may not deallocate!
f(x)
}
fn main() {
inner(Box::leak(Box::new(0)), |x| {
let raw = x as *mut _;
drop(unsafe { Box::from_raw(raw) });
});
}