]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector2.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / deallocate_against_protector2.rs
1 //@error-pattern: /deallocating while item \[SharedReadWrite for .*\] is strongly protected/
2 use std::marker::PhantomPinned;
3
4 pub struct NotUnpin(i32, PhantomPinned);
5
6 fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
7     // `f` may mutate, but it may not deallocate!
8     f(x)
9 }
10
11 fn main() {
12     inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
13         let raw = x as *mut _;
14         drop(unsafe { Box::from_raw(raw) });
15     });
16 }