The docs for ptr::drop_in_place state:
Unaligned values cannot be dropped in place, they must be copied to an aligned location first:
And include an example which uses ptr::copy to copy the value from an unaligned pointer into an aligned one. However, the docs for ptr::copy state:
Both src and dst must be properly aligned.
Either the docs for ptr::copy are wrong, and src does not need to be aligned, or the example for drop_in_place invokes UB and should be updated to use read_unaligned
The docs for
ptr::drop_in_placestate:And include an example which uses
ptr::copyto copy the value from an unaligned pointer into an aligned one. However, the docs forptr::copystate:Either the docs for
ptr::copyare wrong, andsrcdoes not need to be aligned, or the example fordrop_in_placeinvokes UB and should be updated to useread_unaligned