Closed
Description
On Apple Silicon (unlike x86_64) u128
is 16-bytes aligned. So it takes extra space with little or no benefit. I looked at generated code, it is the same:
https://rust.godbolt.org/z/3sE7sMsjj
(Note just using repr(packed(8))
won't work because it will pass TypeId
by reference not by value)
Additionally the issue with current TypeId
is that is has different alignment on different platforms. Rust does not provide guarantees about the alignment, but if this was the same everywhere, it'd make life easier. (Practically we encountered this issue when our CI worked fine on Apple x86_64 macs, but the program didn't work on Apple Silicon.)
rustc 1.74.0-nightly (a991861 2023-09-05)
macOS, Apple Silicon