Coroutine variant fields can be uninitialized
Wrap coroutine variant fields in MaybeUninit to indicate that they
might be uninitialized. Otherwise an uninhabited field will make
the entire variant uninhabited and introduce undefined behaviour.
The analogous issue in the prefix of coroutine layout was addressed by
6fae7f8071
.
This commit is contained in:
parent
5b8bc568d2
commit
a48cebc4b8
5 changed files with 58 additions and 4 deletions
|
@ -831,7 +831,10 @@ fn coroutine_layout<'tcx>(
|
|||
Assigned(_) => bug!("assignment does not match variant"),
|
||||
Ineligible(_) => false,
|
||||
})
|
||||
.map(|local| subst_field(info.field_tys[*local].ty));
|
||||
.map(|local| {
|
||||
let field_ty = subst_field(info.field_tys[*local].ty);
|
||||
Ty::new_maybe_uninit(tcx, field_ty)
|
||||
});
|
||||
|
||||
let mut variant = univariant_uninterned(
|
||||
cx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue