Struct yoke::kinda_sorta_dangling::KindaSortaDangling
source · #[repr(transparent)]pub(crate) struct KindaSortaDangling<T: 'static> {
dangle: MaybeUninit<T>,
}
Expand description
This type is intended to be similar to the type MaybeDangling<T>
proposed in RFC 3336.
The effect of this is that in Rust’s safety model, types inside here are not
expected to have any memory dependent validity properties (dereferenceable
, noalias
).
See #3696 for a testcase where Yoke
fails this under miri’s field-retagging mode.
This has T: 'static
since we don’t need anything
else and we don’t want to have to think (more) about variance over lifetimes or dropck.
After RFC 3336 lands we can use MaybeDangling
instead.
Note that a version of this type also exists publicly as the [maybe_dangling
]
crate; which also exports a patched ManuallyDrop
with similar semantics and
does not require T: 'static
. Consider using this if you need something more general
and are okay with adding dependencies.
Fields§
§dangle: MaybeUninit<T>
Safety invariant: This is always an initialized T, never uninit or other
invalid bit patterns. Its drop glue will execute during Drop::drop rather than
during the drop glue for KindaSortaDangling, which means that we have to be careful about
not touching the values as initialized during drop
after that, but that’s a short period of time.