]> git.lizzy.rs Git - rust.git/blob - tests/fail/stacked_borrows/deallocate_against_barrier1.rs
9b710424c55c4fc1188d3e3d290331c9aaa421b3
[rust.git] / tests / fail / stacked_borrows / deallocate_against_barrier1.rs
1 //@error-pattern: /deallocating while item \[Unique for .*\] is protected/
2
3 fn inner(x: &mut i32, f: fn(&mut i32)) {
4     // `f` may mutate, but it may not deallocate!
5     f(x)
6 }
7
8 fn main() {
9     inner(Box::leak(Box::new(0)), |x| {
10         let raw = x as *mut _;
11         drop(unsafe { Box::from_raw(raw) });
12     });
13 }