Create `assert_field_offsets!` macro
This introduces assert_field_offsets! for ensuring that given struct fields are at specific offsets.
This current implementation works in Rust 1.37 and 1.38. However, the current beta and nightly compilers fail to perform the constant evaluation. This is not unexpected since the current code creates a reference at mem::align_of::<T>(), where there is no initialized memory. Even though the reference is non-null, dereferencing those addresses is definitely undefined behavior.
I won't be merging this PR as-is. However, I'm interested to learn how this macro could be implemented in a sound way.
See also: https://github.com/Gilnaa/memoffset/issues/24.
(cc @oli-obk @RalfJung)
However, I'm interested to learn how this macro could be implemented in a sound way.
Right now, it cannot be implemented soundly. It needs both https://github.com/rust-lang/rust/pull/63810 and https://github.com/rust-lang/rust/pull/64588, as well as allowing &raw in const-context.