Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkov

Remove option_payload_ptr; redundant to offset_of

The `option_payload_ptr` intrinsic is no longer required as `offset_of` supports traversing enums (#114208). This PR removes it in order to dogfood offset_of (as suggested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790907626). However, it will not build until those changes reach beta (which I think is within the next 8 days?) so I've opened it as a draft.
This commit is contained in:
bors 2023-11-18 12:45:42 +00:00
commit 33688d2467
11 changed files with 16 additions and 171 deletions

View file

@ -97,9 +97,11 @@ where
// SAFETY: Loop conditions ensure the index is in bounds.
unsafe {
let opt_payload_at = core::intrinsics::option_payload_ptr(&val);
let opt_payload_at: *const MaybeUninit<B> = (&val as *const Option<B>)
.byte_add(core::mem::offset_of!(Option<B>, Some.0))
.cast();
let dst = guard.array.as_mut_ptr().add(idx);
crate::ptr::copy_nonoverlapping(opt_payload_at.cast(), dst, 1);
crate::ptr::copy_nonoverlapping(opt_payload_at, dst, 1);
crate::mem::forget(val);
};