servo/tendril

tendril::test::assert_sizes fails with Rust 1.64.0+

decathorpe opened this issue · 0 comments

Looks like the expected size of ByteTendril has changed with Rust 1.64.0:

---- tendril::test::assert_sizes stdout ----
thread 'tendril::test::assert_sizes' panicked at 'assertion failed: `(left == right)`
  left: `16`,
 right: `24`', src/tendril.rs:1704:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Line src/tendril.rs:1704 points at this assert:

assert_eq!(correct, mem::size_of::<Option<ByteTendril>>());

The same test passes with Rust 1.63 and earlier.

I can't really see how ByteTendril still has the expected size, but Option<ByteTendril> is now 50% bigger. Unless ... Rust 1.64.0 no longer does "niche" optimization for the Option in this case? I can see how it might be "tempting" to assign a niche for None to the case where the ptr: Cell<NonZeroUsize> is actually zero - but can this ever be correct for a repr(C) struct? I don't see anything that might be related to this problem in the Rust 1.64.0 release notes.