We don't have any general layout rules that hold for all types. But AFAICT for all non-ZSTs, Size >= Alignment.
Shall we document this somewhere ?
We should also probably document for each of the possible ZSTs that their alignment >= size.
The formulation that doesn't need special casing for ZSTs is that "size has to be a multiple of alignment". Which is currently true but trying to document it riles up the "size vs stride" discussion again...
@rkruppe that sounds good - we can add a note, explaining some of the straightforward consequences of that.
I'm not sure where, but the beginning of the layout section might be appropriate
or the glossary
we can define
as long as we keep the reading from the array section, that we might want to change this to support stride>size types
until the lang team tells us "no"^^
this is one of the things I think Rust should have done pre-1.0 :/
I can't really imagine us ever actually doing this change now that we're years past 1.0, but long sigh yeah, in the terminology of the array chapter, it's "stride is a multiple of alignment"
well if I am the only one who thinks it is worthwhile to keep that option open, I am fine being outvoted
it's not like this is so close to my heart. we are not talking about union semantics after all. :P
I would prefer to have a stride, and I'll also would prefer to somehow be able to reuse trailing padding.
I don't know what Swift does here
given the existence of unsafe code that assumes that stride = size, it's unlikely that we'd ever have the ability to change it