Description
So apparently ZST return types are actually returned via a return pointer on windows-gnu targets -- except of course when the return type is ()
. At the same time we promise "Any two types with size 0 and alignment 1 are ABI-compatible". These two things are in direct contradiction with each other. We have to either add something like "except on platforms with a ridiculous ABI, such as windows, then you are just on your own" to the ABI docs, or decide we do not follow the likely accidental ad-hoc ABI of windows-gnu, or emit a hard error for types that the ABI simply does not support.
Note that the reason for this rule of any two 1-ZST being ABI compatible is that for types like #[repr(transparent)] ZST([u8; 0]; ())
, we promise that the type is ABI-compatible with the field that is being transparently wrapped, and that could be either field. So the only way to always deliver on our repr(transparent)
ABI-compatibility promise is to make all 1-ZST ABI-compatible.
This came up in rust-lang/rust#135204.
Cc @programmerjake @ChrisDenton @eddyb