diff options
| author | Ralf Jung <post@ralfj.de> | 2024-09-09 14:42:03 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-09-09 14:46:26 +0200 |
| commit | 65c70900ceda1c276c8eef1dad4e2c4f7a0756d0 (patch) | |
| tree | d14dddfc910871169e06c4b70cc911bb714dd176 /src | |
| parent | 11bd99de8cc67683f215317dba55c91aaf3b5767 (diff) | |
| download | rust-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.rs | 15 |
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(); } |
