rust/tests/compile-fail-fullmir/stacked_borrows/deallocate_against_barrier.rs
2018-11-27 14:26:23 +01:00

14 lines
293 B
Rust

// error-pattern: Deallocating with active barrier
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) });
});
}