diff options
| author | bors <bors@rust-lang.org> | 2023-09-12 06:51:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-12 06:51:36 +0000 |
| commit | 259b4f0b1c91e7808da394ace0f356f9b7465f9c (patch) | |
| tree | c519cbd26971348dc265eaf1e4bb957801eecb8d /src | |
| parent | ea488f786442aeed98ad8158d50a7017c415dec4 (diff) | |
| parent | f8809ab91132b9c9e1625e422e13ff5493ba38e4 (diff) | |
Auto merge of #3060 - RalfJung:abi, r=RalfJung
extra ABI tests, in particular for DispatchFromDyn
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/tests/pass/function_calls/abi_compat.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tools/miri/tests/pass/function_calls/abi_compat.rs b/src/tools/miri/tests/pass/function_calls/abi_compat.rs index 064605d453a..b24fe56cad6 100644 --- a/src/tools/miri/tests/pass/function_calls/abi_compat.rs +++ b/src/tools/miri/tests/pass/function_calls/abi_compat.rs @@ -1,6 +1,7 @@ use std::mem; use std::num; use std::ptr; +use std::rc::Rc; #[derive(Copy, Clone, Default)] struct Zst; @@ -60,8 +61,8 @@ fn test_abi_newtype<T: Copy + Default>() { } fn main() { - // Here we check some of the guaranteed ABI compatibilities. - // Different integer types of the same size and sign. + // Here we check some of the guaranteed ABI compatibilities: + // - Different integer types of the same size and sign. if cfg!(target_pointer_width = "32") { test_abi_compat(0usize, 0u32); test_abi_compat(0isize, 0i32); @@ -70,15 +71,17 @@ fn main() { test_abi_compat(0isize, 0i64); } test_abi_compat(42u32, num::NonZeroU32::new(1).unwrap()); - // Reference/pointer types with the same pointee. + // - Reference/pointer types with the same pointee. test_abi_compat(&0u32, &0u32 as *const u32); test_abi_compat(&mut 0u32 as *mut u32, Box::new(0u32)); test_abi_compat(&(), ptr::NonNull::<()>::dangling()); - // Reference/pointer types with different but sized pointees. + // - Reference/pointer types with different but sized pointees. test_abi_compat(&0u32, &([true; 4], [0u32; 0])); - // `fn` types + // - `fn` types test_abi_compat(main as fn(), id::<i32> as fn(i32) -> i32); - // Guaranteed null-pointer-optimizations. + // - 1-ZST + test_abi_compat((), [0u8; 0]); + // - Guaranteed null-pointer-optimizations. test_abi_compat(&0u32 as *const u32, Some(&0u32)); test_abi_compat(main as fn(), Some(main as fn())); test_abi_compat(0u32, Some(num::NonZeroU32::new(1).unwrap())); @@ -96,4 +99,11 @@ fn main() { test_abi_newtype::<[u32; 0]>(); test_abi_newtype::<[u32; 2]>(); test_abi_newtype::<[u32; 32]>(); + test_abi_newtype::<Option<i32>>(); + test_abi_newtype::<Option<num::NonZeroU32>>(); + + // Extra test for assumptions made by arbitrary-self-dyn-receivers. + let rc = Rc::new(0); + let rc_ptr: *mut i32 = unsafe { mem::transmute_copy(&rc) }; + test_abi_compat(rc, rc_ptr); } |
