about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-07-12 07:29:36 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-07-12 07:29:36 +0000
commit726919629e0ca3660a41843f9565469e5dd2b2d9 (patch)
tree0c7f00640de1270f8597e948e43b5a7e593d51b9
parent24e87965ae35843fe340a5104482be1d1f827af7 (diff)
downloadrust-726919629e0ca3660a41843f9565469e5dd2b2d9.tar.gz
rust-726919629e0ca3660a41843f9565469e5dd2b2d9.zip
Always check Cell alongside with `UnsafeCell`
-rw-r--r--src/test/ui/layout/unsafe-cell-hides-niche.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/ui/layout/unsafe-cell-hides-niche.rs b/src/test/ui/layout/unsafe-cell-hides-niche.rs
index e82eaa38612..fce101d7bb1 100644
--- a/src/test/ui/layout/unsafe-cell-hides-niche.rs
+++ b/src/test/ui/layout/unsafe-cell-hides-niche.rs
@@ -26,11 +26,23 @@ macro_rules! check_sizes {
     (check_one_specific_size: $ty:ty, $size:expr) => {
         const _: Size::<{$size}> = Size::<{size_of::<$ty>()}>;
     };
+    // Any tests run on `UnsafeCell` must be the same for `Cell`
+    (UnsafeCell<$ty:ty>: $size:expr => $optioned_size:expr) => {
+        check_sizes!(Cell<$ty>: $size => $optioned_size);
+        check_sizes!(@actual_check: UnsafeCell<$ty>: $size => $optioned_size);
+    };
     ($ty:ty: $size:expr => $optioned_size:expr) => {
+        check_sizes!(@actual_check: $ty: $size => $optioned_size);
+    };
+    // This branch does the actual checking logic, the `@actual_check` prefix is here to distinguish
+    // it from other branches and not accidentally match any.
+    (@actual_check: $ty:ty: $size:expr => $optioned_size:expr) => {
         check_sizes!(check_one_specific_size: $ty, $size);
         check_sizes!(check_one_specific_size: Option<$ty>, $optioned_size);
         check_sizes!(check_no_niche_opt: $size != $optioned_size, $ty);
     };
+    // only check that there is no niche (size goes up when wrapped in an option),
+    // don't check actual sizes
     ($ty:ty) => {
         check_sizes!(check_no_niche_opt: true, $ty);
     };
@@ -52,7 +64,6 @@ check_sizes!(UnsafeCell<u32>:  4 => 8);
 check_sizes!(UnsafeCell<N32>:  4 => 8);
 
 check_sizes!(UnsafeCell<&()>: PTR_SIZE => PTR_SIZE * 2);
-check_sizes!(      Cell<&()>: PTR_SIZE => PTR_SIZE * 2);
 check_sizes!(   RefCell<&()>: PTR_SIZE * 2 => PTR_SIZE * 3);
 
 check_sizes!(RwLock<&()>);