2019-05-17 06:42:36 -05:00
|
|
|
// error-pattern: deallocating while item is protected
|
2018-11-21 08:25:47 -06:00
|
|
|
|
|
|
|
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) });
|
|
|
|
});
|
|
|
|
}
|