Skip to content

Commit 24f4df1

Browse files
committed
when -Zrandomize-layout is enabled disable alloc test testing internal struct sizes
1 parent db71053 commit 24f4df1

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

library/alloc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ check-cfg = [
5252
'cfg(no_global_oom_handling)',
5353
'cfg(no_rc)',
5454
'cfg(no_sync)',
55+
'cfg(randomized_layouts)',
5556
]

library/alloc/src/collections/btree/node/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn test_partial_eq() {
9090

9191
#[test]
9292
#[cfg(target_arch = "x86_64")]
93-
#[cfg_attr(miri, ignore)] // We'd like to run Miri with layout randomization
93+
#[cfg_attr(any(miri, randomized_layouts), ignore)] // We'd like to run Miri with layout randomization
9494
fn test_sizes() {
9595
assert_eq!(core::mem::size_of::<LeafNode<(), ()>>(), 16);
9696
assert_eq!(core::mem::size_of::<LeafNode<i64, i64>>(), 16 + CAPACITY * 2 * 8);

src/bootstrap/src/core/builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,9 @@ impl<'a> Builder<'a> {
21932193
rustflags.arg("-Zvalidate-mir");
21942194
rustflags.arg(&format!("-Zmir-opt-level={mir_opt_level}"));
21952195
}
2196+
if self.config.rust_randomize_layout {
2197+
rustflags.arg("--cfg=randomized_layouts");
2198+
}
21962199
// Always enable inlining MIR when building the standard library.
21972200
// Without this flag, MIR inlining is disabled when incremental compilation is enabled.
21982201
// That causes some mir-opt tests which inline functions from the standard library to

0 commit comments

Comments
 (0)