diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-20 16:54:36 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-20 17:00:13 +0200 |
| commit | a281f93d3d06be1ef8a1a521fab9c049901da64d (patch) | |
| tree | b5a2870e87543e8fdd42935a5339dcc3a98db502 /compiler/rustc_ty_utils | |
| parent | a971212545766fdfe0dd68e5d968133f79944a19 (diff) | |
| download | rust-a281f93d3d06be1ef8a1a521fab9c049901da64d.tar.gz rust-a281f93d3d06be1ef8a1a521fab9c049901da64d.zip | |
supress niches in coroutines
Diffstat (limited to 'compiler/rustc_ty_utils')
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 234e1a6d55e..c23a7fec5a5 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -1001,7 +1001,13 @@ fn coroutine_layout<'tcx>( }, fields: outer_fields, abi, - largest_niche: prefix.largest_niche, + // Suppress niches inside coroutines. If the niche is inside a field that is aliased (due to + // self-referentiality), getting the discriminant can cause aliasing violations. + // `UnsafeCell` blocks niches for the same reason, but we don't yet have `UnsafePinned` that + // would do the same for us here. + // See <https://github.com/rust-lang/rust/issues/63818>, <https://github.com/rust-lang/miri/issues/3780>. + // FIXME: Remove when <https://github.com/rust-lang/rust/issues/125735> is implemented and aliased coroutine fields are wrapped in `UnsafePinned`. + largest_niche: None, size, align, max_repr_align: None, |
