Skip to content

Commit cb9fa6d

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

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+3
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ impl<'a, 'tcx> Collector<'a, 'tcx> {
811811
map: &Map<'tcx>,
812812
) -> Option<Const<'tcx>> {
813813
let ty = place.ty(self.local_decls, self.patch.tcx).ty;
814+
if ty.is_async_drop_in_place_coroutine(self.patch.tcx) {
815+
return None;
816+
}
814817
let layout = ecx.layout_of(ty).ok()?;
815818

816819
if layout.is_zst() {
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)