Skip to content

Commit 13178c7

Browse files
committed
Async drop fix for async_drop_in_place<T> layout calculated for unspecified T
1 parent b105556 commit 13178c7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

compiler/rustc_middle/src/ty/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,9 @@ impl<'tcx> TyCtxt<'tcx> {
19241924
def_id: DefId,
19251925
args: GenericArgsRef<'tcx>,
19261926
) -> Option<&'tcx CoroutineLayout<'tcx>> {
1927+
if args[0].has_placeholders() || args[0].has_non_region_param() {
1928+
return None;
1929+
}
19271930
let instance = InstanceKind::AsyncDropGlue(def_id, Ty::new_coroutine(self, def_id, args));
19281931
self.mir_shims(instance).coroutine_layout_raw()
19291932
}
Original file line numberDiff line numberDiff 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| &mut **g) };
19+
let h = unsafe { async_drop_in_place(f.get_unchecked_mut()) };
20+
h;
21+
}

0 commit comments

Comments
 (0)