Open
Description
I tried this code:
use std::num::NonZeroU8;
struct Test {
niche_one: NonZeroU8,
niche_two: NonZeroU8,
}
fn main() {
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.
Meta
rustc --version --verbose
:
rustc 1.77.0-nightly (e51e98dde 2023-12-31)
binary: rustc
commit-hash: e51e98dde6a60637b6a71b8105245b629ac3fe77
commit-date: 2023-12-31
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6