[Pre-RFC] Improved Unsizing

The theory is that this isn't true, and it's possible to fix exactly one field to the unsizable position and still provide a structure layout with the same Layout.

What even allows this to exist rather than be trivial to make a counterexample is that struct layout is always padded to alignment. This means that in the case where the tail type is the most aligned, you can trivially find a solution with it in the unsizable position by doing an alignment sorting layout, padding to alignment (as required by #[repr(Rust)] and Rust's allocation APIs), and then reversing the order of the fields and padding such that the padding is towards the top of the struct layout instead of the bottom.

@quaternic provided a proof that you can always turn your optimal layout into one with the tail type in the fixed final position here: [Pre-RFC] Improved Unsizing - #17 by quaternic; you're asserting that the proof is flawed (which is possible, to be completely fair).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.