rust/tests/fail/stacked_borrows/deallocate_against_protector1.rs
Ralf Jung abe890d2ce slightly improve protector-related error messages
also rename some tests that still used outdated "barrier" terminology
2022-08-28 09:27:10 -04:00

14 lines
317 B
Rust

//@error-pattern: /deallocating while item \[Unique for .*\] 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) });
});
}