about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-09-09 14:42:03 +0200
committerRalf Jung <post@ralfj.de>2024-09-09 14:46:26 +0200
commit65c70900ceda1c276c8eef1dad4e2c4f7a0756d0 (patch)
treed14dddfc910871169e06c4b70cc911bb714dd176 /src
parent11bd99de8cc67683f215317dba55c91aaf3b5767 (diff)
downloadrust-65c70900ceda1c276c8eef1dad4e2c4f7a0756d0.tar.gz
rust-65c70900ceda1c276c8eef1dad4e2c4f7a0756d0.zip
union padding computation: add fast-path for ZST
Also avoid even tracking empty ranges, and add fast-path for arrays of scalars
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/tests/pass/arrays.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/arrays.rs b/src/tools/miri/tests/pass/arrays.rs
index 61b44453e9b..b0c6f54cab8 100644
--- a/src/tools/miri/tests/pass/arrays.rs
+++ b/src/tools/miri/tests/pass/arrays.rs
@@ -61,6 +61,20 @@ fn debug() {
     println!("{:?}", array);
 }
 
+fn huge_zst() {
+    fn id<T>(x: T) -> T { x }
+
+    // A "huge" zero-sized array. Make sure we don't loop over it in any part of Miri.
+    let val = [(); usize::MAX];
+    id(val); // make a copy
+
+    let val = [val; 2];
+    id(val);
+
+    // Also wrap it in a union (which, in particular, hits the logic for computing union padding).
+    let _copy = std::mem::MaybeUninit::new(val);
+}
+
 fn main() {
     assert_eq!(empty_array(), []);
     assert_eq!(index_unsafe(), 20);
@@ -73,4 +87,5 @@ fn main() {
     from();
     eq();
     debug();
+    huge_zst();
 }