diff options
| author | bors <bors@rust-lang.org> | 2023-09-02 01:09:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-02 01:09:07 +0000 |
| commit | d2f5dc9745defa7cb90a88dd8adc7d347f42d0bc (patch) | |
| tree | 844e81761610cf39374be4461a26f8c345a48a97 | |
| parent | cae8f934f56216abbed5a6242d455a1e043caed6 (diff) | |
| parent | 97ee83068d2b542df30245ba476b891b7969e8f3 (diff) | |
| download | rust-d2f5dc9745defa7cb90a88dd8adc7d347f42d0bc.tar.gz rust-d2f5dc9745defa7cb90a88dd8adc7d347f42d0bc.zip | |
Auto merge of #3049 - RalfJung:rustup, r=RalfJung
Rustup
| -rw-r--r-- | src/tools/miri/rust-version | 2 | ||||
| -rw-r--r-- | src/tools/miri/tests/pass/function_calls/abi_compat.rs | 26 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index f173cc37e85..919bc135fdf 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -dca2d1ff00bf96d244b1bb9a2117a92ec50ac71d +35e416303e6591a71ef6a91e006c602d2def3968 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 60baf8e72e8..08be29115ca 100644 --- a/src/tools/miri/tests/pass/function_calls/abi_compat.rs +++ b/src/tools/miri/tests/pass/function_calls/abi_compat.rs @@ -1,7 +1,7 @@ use std::mem; use std::num; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Default)] struct Zst; fn test_abi_compat<T: Copy, U: Copy>(t: T, u: U) { @@ -31,7 +31,7 @@ fn test_abi_compat<T: Copy, U: Copy>(t: T, u: U) { } /// Ensure that `T` is compatible with various repr(transparent) wrappers around `T`. -fn test_abi_newtype<T: Copy>(t: T) { +fn test_abi_newtype<T: Copy + Default>() { #[repr(transparent)] #[derive(Copy, Clone)] struct Wrapper1<T>(T); @@ -45,6 +45,7 @@ fn test_abi_newtype<T: Copy>(t: T) { #[derive(Copy, Clone)] struct Wrapper3<T>(Zst, T, [u8; 0]); + let t = T::default(); test_abi_compat(t, Wrapper1(t)); test_abi_compat(t, Wrapper2(t, ())); test_abi_compat(t, Wrapper2a((), t)); @@ -62,21 +63,24 @@ fn main() { // these would be stably guaranteed. Code that relies on this is equivalent to code that relies // on the layout of `repr(Rust)` types. They are also fragile: the same mismatches in the fields // of a struct (even with `repr(C)`) will not always be accepted by Miri. + // Note that `bool` and `u8` are *not* compatible, at least on x86-64! + // One of them has `arg_ext: Zext`, the other does not. + // Similarly, `i32` and `u32` are not compatible on s390x due to different `arg_ext`. test_abi_compat(0u32, 'x'); test_abi_compat(42u32, num::NonZeroU32::new(1).unwrap()); test_abi_compat(0u32, Some(num::NonZeroU32::new(1).unwrap())); test_abi_compat(&0u32, &0u32 as *const u32); test_abi_compat(&0u32, &([true; 4], [0u32; 0])); - // Note that `bool` and `u8` are *not* compatible, at least on x86-64! - // One of them has `arg_ext: Zext`, the other does not. // These must work for *any* type, since we guarantee that `repr(transparent)` is ABI-compatible // with the wrapped field. - test_abi_newtype(()); - // FIXME: this still fails! test_abi_newtype(Zst); - test_abi_newtype(0u32); - test_abi_newtype(0f32); - test_abi_newtype((0u32, 1u32, 2u32)); - test_abi_newtype([0u32, 1u32, 2u32]); - test_abi_newtype([0i32; 0]); + test_abi_newtype::<()>(); + test_abi_newtype::<Zst>(); + test_abi_newtype::<u32>(); + test_abi_newtype::<f32>(); + test_abi_newtype::<(u8, u16, f32)>(); + test_abi_newtype::<[u8; 0]>(); + test_abi_newtype::<[u32; 0]>(); + test_abi_newtype::<[u32; 2]>(); + test_abi_newtype::<[u32; 32]>(); } |
