Description
Moved to #1818.
Historically, we've avoided adding these impls for fear that they could present a footgun, making it easier to accidentally transmute into a type, breaking its safety invariants.
Today, I was working on replacing some unsafe
code in Fuchsia's Starnix project with zerocopy, and ran into some structs for which I can't derive FromBytes
or AsBytes
because they contain raw pointers. Currently, the lack of impls on raw pointers is entirely preventing this unsafe
code from being replaced by zerocopy, which feels to me like throwing the baby out with the bathwater. IMO, it's more important to unlock this use case than to avoid a minor and theoretical footgun.
Note that, while the layout of raw pointers is well-defined, it's less clear that their bit validity is well-defined.
TODO: