@@ -26,11 +26,23 @@ macro_rules! check_sizes {
2626 ( check_one_specific_size: $ty: ty, $size: expr) => {
2727 const _: Size :: <{ $size} > = Size :: <{ size_of:: <$ty>( ) } >;
2828 } ;
29+ // Any tests run on `UnsafeCell` must be the same for `Cell`
30+ ( UnsafeCell <$ty: ty>: $size: expr => $optioned_size: expr) => {
31+ check_sizes!( Cell <$ty>: $size => $optioned_size) ;
32+ check_sizes!( @actual_check: UnsafeCell <$ty>: $size => $optioned_size) ;
33+ } ;
2934 ( $ty: ty: $size: expr => $optioned_size: expr) => {
35+ check_sizes!( @actual_check: $ty: $size => $optioned_size) ;
36+ } ;
37+ // This branch does the actual checking logic, the `@actual_check` prefix is here to distinguish
38+ // it from other branches and not accidentally match any.
39+ ( @actual_check: $ty: ty: $size: expr => $optioned_size: expr) => {
3040 check_sizes!( check_one_specific_size: $ty, $size) ;
3141 check_sizes!( check_one_specific_size: Option <$ty>, $optioned_size) ;
3242 check_sizes!( check_no_niche_opt: $size != $optioned_size, $ty) ;
3343 } ;
44+ // only check that there is no niche (size goes up when wrapped in an option),
45+ // don't check actual sizes
3446 ( $ty: ty) => {
3547 check_sizes!( check_no_niche_opt: true , $ty) ;
3648 } ;
@@ -52,7 +64,6 @@ check_sizes!(UnsafeCell<u32>: 4 => 8);
5264check_sizes ! ( UnsafeCell <N32 >: 4 => 8 ) ;
5365
5466check_sizes ! ( UnsafeCell <& ( ) >: PTR_SIZE => PTR_SIZE * 2 ) ;
55- check_sizes ! ( Cell <& ( ) >: PTR_SIZE => PTR_SIZE * 2 ) ;
5667check_sizes ! ( RefCell <& ( ) >: PTR_SIZE * 2 => PTR_SIZE * 3 ) ;
5768
5869check_sizes ! ( RwLock <& ( ) >) ;
0 commit comments