Auto merge of #140918 - pietroalbini:pa-backport-140902, r=pietroalbini · rust-lang/rust@5dadfd5 (original) (raw)
File tree
2 files changed
lines changed
- compiler/rustc_middle/src/ty
- tests/ui/async-await/async-drop
2 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1924,6 +1924,9 @@ impl<'tcx> TyCtxt<'tcx> { | ||
| 1924 | 1924 | def_id: DefId, |
| 1925 | 1925 | args: GenericArgsRef<'tcx>, |
| 1926 | 1926 | ) -> Option<&'tcx CoroutineLayout<'tcx>> { |
| 1927 | +if args[0].has_placeholders() | | |
| 1928 | +return None; | |
| 1929 | +} | |
| 1927 | 1930 | let instance = InstanceKind::AsyncDropGlue(def_id, Ty::new_coroutine(self, def_id, args)); |
| 1928 | 1931 | self.mir_shims(instance).coroutine_layout_raw() |
| 1929 | 1932 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 1 | +//@ compile-flags: -Zmir-enable-passes=+DataflowConstProp | |
| 2 | +//@ edition: 2021 | |
| 3 | +//@ build-pass | |
| 4 | +#![feature(async_drop)] | |
| 5 | +#![allow(incomplete_features)] | |
| 6 | + | |
| 7 | +use std::mem::ManuallyDrop; | |
| 8 | +use std::{ | |
| 9 | + future::async_drop_in_place, | |
| 10 | + pin::{pin, Pin}, | |
| 11 | +}; | |
| 12 | +fn main() { | |
| 13 | +a(b) | |
| 14 | +} | |
| 15 | +fn b() {} | |
| 16 | +fn a<C>(d: C) { | |
| 17 | +let e = pin!(ManuallyDrop::new(d)); | |
| 18 | +let f = unsafe { Pin::map_unchecked_mut(e, |g | |
| 19 | +let h = unsafe { async_drop_in_place(f.get_unchecked_mut()) }; | |
| 20 | + h; | |
| 21 | +} |