You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missed layout optimisation with multiple niches #119507
use std::num::NonZeroU8;structTest{niche_one:NonZeroU8,niche_two:NonZeroU8,}fnmain(){assert_eq!(
std::mem::size_of::<Test>(),
std::mem::size_of::<Option<Option<Test>>>());}
I expected this program to exit fine, and fit the tag of the second option in the available niche.
Instead, the program panics, as the second option wastes a byte of memory making it's own tag byte.
I'm pretty sure we already have an issue for this, but I can't find one that's written clearly. #101567 was the first one that clearly looks like a duplicate when I was scrolling.
The problem is that the rustc layout representation (in this case of Test) only represents a single contiguous niche with a single contiuous (albeit wrapping) range of niche values. That should be (probably is somewhere) tracked in an issue.
Activity
Get rid of NonEmptyArray
saethlin commentedon Jan 2, 2024
I'm pretty sure we already have an issue for this, but I can't find one that's written clearly. #101567 was the first one that clearly looks like a duplicate when I was scrolling.
The problem is that the rustc layout representation (in this case of
Test) only represents a single contiguous niche with a single contiuous (albeit wrapping) range of niche values. That should be (probably is somewhere) tracked in an issue.Add another niche to FixedArray