diff options
Diffstat (limited to 'tests/ui/async-await/async-drop')
| -rw-r--r-- | tests/ui/async-await/async-drop/open-drop-error.rs | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/tests/ui/async-await/async-drop/open-drop-error.rs b/tests/ui/async-await/async-drop/open-drop-error.rs new file mode 100644 index 00000000000..1d97eee5210 --- /dev/null +++ b/tests/ui/async-await/async-drop/open-drop-error.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Zmir-enable-passes=+DataflowConstProp +//@ edition: 2021 +//@ build-pass +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; +use std::{ + future::async_drop_in_place, + pin::{pin, Pin}, +}; +fn main() { + a(b) +} +fn b() {} +fn a<C>(d: C) { + let e = pin!(ManuallyDrop::new(d)); + let f = unsafe { Pin::map_unchecked_mut(e, |g| &mut **g) }; + let h = unsafe { async_drop_in_place(f.get_unchecked_mut()) }; + h; +} | 
