]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs
Rollup merge of #105784 - yanns:update_stdarch, r=Amanieu
[rust.git] / src / tools / miri / tests / pass / stacked-borrows / no_field_retagging.rs
1 //@compile-flags: -Zmiri-retag-fields=none
2
3 struct Newtype<'a>(&'a mut i32);
4
5 fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
6     dealloc();
7 }
8
9 // Make sure that we do *not* retag the fields of `Newtype`.
10 fn main() {
11     let ptr = Box::into_raw(Box::new(0i32));
12     #[rustfmt::skip] // I like my newlines
13     unsafe {
14         dealloc_while_running(
15             Newtype(&mut *ptr),
16             || drop(Box::from_raw(ptr)),
17         )
18     };
19 }