You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TransmuteFrom models 'union transmute', which permits extensions of the trailing padding bytes of Src during the transmutation to Dst. This model is implemented by TransmuteFrom::transmute, which uses a union to perform the transmutation. Essentially:
Unfortunately, this long-form implementation might be quite heavy on the optimizer. For example, using ManuallyDrop can cause memcpys and allocas that LLVM cannot remove: rust-lang/rust#79914
It would therefore be nice to have a intrinsic version of this that wasn't so dependent on the optimizer. We could either, as @scottmcm suggests, modify transmute_unchecked to provide these semantics, or we could provide a new intrinsic (e.g., transmute_union) that provides these semantics.
The text was updated successfully, but these errors were encountered:
it immediately occurs to me that the point of a ManuallyDrop is to prevent dropping, but it does that by being a union, so you're just sticking a union into a union... so you can just remove the ManuallyDrop layer
TransmuteFrom
models 'union transmute', which permits extensions of the trailing padding bytes ofSrc
during the transmutation toDst
. This model is implemented byTransmuteFrom::transmute
, which uses a union to perform the transmutation. Essentially:Unfortunately, this long-form implementation might be quite heavy on the optimizer. For example, using
ManuallyDrop
can causememcpy
s andalloca
s that LLVM cannot remove: rust-lang/rust#79914It would therefore be nice to have a intrinsic version of this that wasn't so dependent on the optimizer. We could either, as @scottmcm suggests, modify
transmute_unchecked
to provide these semantics, or we could provide a new intrinsic (e.g.,transmute_union
) that provides these semantics.The text was updated successfully, but these errors were encountered: