about summary refs log tree commit diff
path: root/compiler/rustc_index/src/lib.rs
diff options
context:
space:
mode:
authorThe 8472 <git@infinite-source.de>2022-09-02 20:17:20 +0200
committerThe 8472 <git@infinite-source.de>2024-08-31 23:56:45 +0200
commit5bf8eeb9f34a738ebf49328c08d40951374cce18 (patch)
tree2adea59c80689ee29e9022e4290e66919f118402 /compiler/rustc_index/src/lib.rs
parentf3bc08adbd120a12571373b982b39049cbbed93f (diff)
downloadrust-5bf8eeb9f34a738ebf49328c08d40951374cce18.tar.gz
rust-5bf8eeb9f34a738ebf49328c08d40951374cce18.zip
disable size asserts in the compiler when randomizing layouts
Diffstat (limited to 'compiler/rustc_index/src/lib.rs')
-rw-r--r--compiler/rustc_index/src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_index/src/lib.rs b/compiler/rustc_index/src/lib.rs
index f773b5b46ad..52f354b8eca 100644
--- a/compiler/rustc_index/src/lib.rs
+++ b/compiler/rustc_index/src/lib.rs
@@ -33,8 +33,19 @@ pub use vec::IndexVec;
 ///
 /// </div>
 #[macro_export]
+#[cfg(not(feature = "rustc_randomized_layouts"))]
 macro_rules! static_assert_size {
     ($ty:ty, $size:expr) => {
         const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
     };
 }
+
+#[macro_export]
+#[cfg(feature = "rustc_randomized_layouts")]
+macro_rules! static_assert_size {
+    ($ty:ty, $size:expr) => {
+        // no effect other than using the statements.
+        // struct sizes are not deterministic under randomized layouts
+        const _: (usize, usize) = ($size, ::std::mem::size_of::<$ty>());
+    };
+}