@@ -321,23 +321,26 @@ fn kind_from_prim(ek: u32) -> Option<ErrorKind> {
321321// that our encoding relies on for correctness and soundness. (Some of these are
322322// a bit overly thorough/cautious, admittedly)
323323//
324- // If any of these are hit on a platform that libstd supports, we should just
325- // make sure `repr_unpacked.rs` is used instead.
324+ // If any of these are hit on a platform that libstd supports, we should likely
325+ // just use `repr_unpacked.rs` there instead (unless the fix is easy) .
326326macro_rules! static_assert {
327327 ( $condition: expr) => {
328- const _: [ ( ) ; 0 ] = [ ( ) ; ( !$condition) as usize ] ;
328+ const _: ( ) = assert!( $condition) ;
329+ } ;
330+ ( @usize_eq: $lhs: expr, $rhs: expr) => {
331+ const _: [ ( ) ; $lhs] = [ ( ) ; $rhs] ;
329332 } ;
330333}
331334
332335// The bitpacking we use requires pointers be exactly 64 bits.
333- static_assert ! ( size_of:: <NonNull <( ) >>( ) == 8 ) ;
336+ static_assert ! ( @usize_eq : size_of:: <NonNull <( ) >>( ) , 8 ) ;
334337
335338// We also require pointers and usize be the same size.
336- static_assert ! ( size_of:: <NonNull <( ) >>( ) == size_of:: <usize >( ) ) ;
339+ static_assert ! ( @usize_eq : size_of:: <NonNull <( ) >>( ) , size_of:: <usize >( ) ) ;
337340
338341// `Custom` and `SimpleMessage` need to be thin pointers.
339- static_assert ! ( size_of:: <& ' static SimpleMessage >( ) == 8 ) ;
340- static_assert ! ( size_of:: <Box <Custom >>( ) == 8 ) ;
342+ static_assert ! ( @usize_eq : size_of:: <& ' static SimpleMessage >( ) , 8 ) ;
343+ static_assert ! ( @usize_eq : size_of:: <Box <Custom >>( ) , 8 ) ;
341344
342345// And they must have >= 4 byte alignment.
343346static_assert ! ( align_of:: <SimpleMessage >( ) >= 4 ) ;
@@ -346,20 +349,21 @@ static_assert!(align_of::<Custom>() >= 4);
346349// This is obviously true (`TAG_CUSTOM` is `0b01`), but our implementation of
347350// `Repr::new_custom` and such would be wrong if it were not, so we check.
348351static_assert ! ( size_of:: <Custom >( ) >= TAG_CUSTOM ) ;
352+
349353// These two store a payload which is allowed to be zero, so they must be
350354// non-zero to preserve the `NonNull`'s range invariant.
351355static_assert ! ( TAG_OS != 0 ) ;
352356static_assert ! ( TAG_SIMPLE != 0 ) ;
353357// We can't tag `SimpleMessage`s, the tag must be 0.
354- static_assert ! ( TAG_SIMPLE_MESSAGE == 0 ) ;
358+ static_assert ! ( @usize_eq : TAG_SIMPLE_MESSAGE , 0 ) ;
355359
356360// Check that the point of all of this still holds.
357361//
358362// We'd check against `io::Error`, but *technically* it's allowed to vary,
359363// as it's not `#[repr(transparent)]`/`#[repr(C)]`. We could add that, but
360364// the `#[repr()]` would show up in rustdoc, which might be seen as a stable
361365// commitment.
362- static_assert ! ( size_of:: <Repr >( ) == 8 ) ;
363- static_assert ! ( size_of:: <Option <Repr >>( ) == 8 ) ;
364- static_assert ! ( size_of:: <Result <( ) , Repr >>( ) == 8 ) ;
365- static_assert ! ( size_of:: <Result <usize , Repr >>( ) == 16 ) ;
366+ static_assert ! ( @usize_eq : size_of:: <Repr >( ) , 8 ) ;
367+ static_assert ! ( @usize_eq : size_of:: <Option <Repr >>( ) , 8 ) ;
368+ static_assert ! ( @usize_eq : size_of:: <Result <( ) , Repr >>( ) , 8 ) ;
369+ static_assert ! ( @usize_eq : size_of:: <Result <usize , Repr >>( ) , 16 ) ;
0 commit comments