diff --git a/tests/meta.rs b/tests/meta.rs index 0c573ccda..31caf6b4d 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -93,24 +93,25 @@ fn alignment() { fn size() { macro_rules! assert_size { ($t:ty, $size:literal, $opt_size:literal) => { - assert_eq!( - ::core::mem::size_of::<$t>(), - $size, - concat!("size of `{}` used to be ", $size), + assert!( + ::core::mem::size_of::<$t>() <= $size, + concat!("size of `{}` used to be ", $size, ", but is now {}"), stringify!($t), + ::core::mem::size_of::<$t>(), ); - assert_eq!( - ::core::mem::size_of::>(), - $opt_size, - concat!("size of `Option<{}>` used to be ", $opt_size), + assert!( + ::core::mem::size_of::>() <= $opt_size, + concat!( + "size of `Option<{}>` used to be ", + $opt_size, + ", but is now {}" + ), stringify!($t), + ::core::mem::size_of::>(), ); }; } - // A couple structs have their size decrease from 56 to 48 thanks to a compiler change. This - // change looks like it will land in 1.64 (2022-09-22). - assert_size!(Date, 4, 8); assert_size!(Duration, 16, 16); assert_size!(OffsetDateTime, 16, 16); @@ -150,13 +151,13 @@ fn size() { assert_size!(Parsed, 56, 56); assert_size!(Month, 1, 1); assert_size!(Weekday, 1, 1); - // assert_size!(Error, 56, 56); + assert_size!(Error, 56, 56); assert_size!(error::Format, 24, 24); assert_size!(error::InvalidFormatDescription, 48, 48); - // assert_size!(error::Parse, 56, 56); + assert_size!(error::Parse, 48, 48); assert_size!(error::ParseFromDescription, 16, 24); assert_size!(error::TryFromParsed, 48, 48); - assert_size!(Component, 6, 6); + assert_size!(Component, 6, 6); // TODO Size is 4 starting with rustc 1.71. assert_size!(FormatItem<'_>, 24, 24); assert_size!(modifier::MonthRepr, 1, 1); assert_size!(modifier::Padding, 1, 1);