Description
Spun off from #36 (comment) and previous.
Currently layout guarantees either come from explicit choices (adding repr
) or follow from other guarantees (e.g. all-pub
struct). #36 aims to introduce a new compiler guarantee that automatically applies to some repr(Rust)
structs and would make field reordering a breaking change for unsafe code relying on that compiler guarantee.
The question is whether unsafe code could reasonably expect these guarantees to be upheld by other crates across minor version bumps.
If yes this would place a new requirement on crate authors and those requirements can be subtle if a struct contains generic fields which would make it sometimes homogeneous and sometimes not.
If no then crate authors would have to explicitly provide this guarantee either via comment or some annotation that can be checked by the compiler or semver linters and unsafe code may need compile-time checks that its assumptions still remain true. There also is the risk that unsafe code authors may conflate compiler guarantees with semver guarantees.