Skip to content

Commit d2f5dc9

Browse files
committed
Auto merge of rust-lang#3049 - RalfJung:rustup, r=RalfJung
Rustup
2 parents cae8f93 + 97ee830 commit d2f5dc9

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dca2d1ff00bf96d244b1bb9a2117a92ec50ac71d
1+
35e416303e6591a71ef6a91e006c602d2def3968

src/tools/miri/tests/pass/function_calls/abi_compat.rs

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::mem;
22
use std::num;
33

4-
#[derive(Copy, Clone)]
4+
#[derive(Copy, Clone, Default)]
55
struct Zst;
66

77
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) {
3131
}
3232

3333
/// Ensure that `T` is compatible with various repr(transparent) wrappers around `T`.
34-
fn test_abi_newtype<T: Copy>(t: T) {
34+
fn test_abi_newtype<T: Copy + Default>() {
3535
#[repr(transparent)]
3636
#[derive(Copy, Clone)]
3737
struct Wrapper1<T>(T);
@@ -45,6 +45,7 @@ fn test_abi_newtype<T: Copy>(t: T) {
4545
#[derive(Copy, Clone)]
4646
struct Wrapper3<T>(Zst, T, [u8; 0]);
4747

48+
let t = T::default();
4849
test_abi_compat(t, Wrapper1(t));
4950
test_abi_compat(t, Wrapper2(t, ()));
5051
test_abi_compat(t, Wrapper2a((), t));
@@ -62,21 +63,24 @@ fn main() {
6263
// these would be stably guaranteed. Code that relies on this is equivalent to code that relies
6364
// on the layout of `repr(Rust)` types. They are also fragile: the same mismatches in the fields
6465
// of a struct (even with `repr(C)`) will not always be accepted by Miri.
66+
// Note that `bool` and `u8` are *not* compatible, at least on x86-64!
67+
// One of them has `arg_ext: Zext`, the other does not.
68+
// Similarly, `i32` and `u32` are not compatible on s390x due to different `arg_ext`.
6569
test_abi_compat(0u32, 'x');
6670
test_abi_compat(42u32, num::NonZeroU32::new(1).unwrap());
6771
test_abi_compat(0u32, Some(num::NonZeroU32::new(1).unwrap()));
6872
test_abi_compat(&0u32, &0u32 as *const u32);
6973
test_abi_compat(&0u32, &([true; 4], [0u32; 0]));
70-
// Note that `bool` and `u8` are *not* compatible, at least on x86-64!
71-
// One of them has `arg_ext: Zext`, the other does not.
7274

7375
// These must work for *any* type, since we guarantee that `repr(transparent)` is ABI-compatible
7476
// with the wrapped field.
75-
test_abi_newtype(());
76-
// FIXME: this still fails! test_abi_newtype(Zst);
77-
test_abi_newtype(0u32);
78-
test_abi_newtype(0f32);
79-
test_abi_newtype((0u32, 1u32, 2u32));
80-
test_abi_newtype([0u32, 1u32, 2u32]);
81-
test_abi_newtype([0i32; 0]);
77+
test_abi_newtype::<()>();
78+
test_abi_newtype::<Zst>();
79+
test_abi_newtype::<u32>();
80+
test_abi_newtype::<f32>();
81+
test_abi_newtype::<(u8, u16, f32)>();
82+
test_abi_newtype::<[u8; 0]>();
83+
test_abi_newtype::<[u32; 0]>();
84+
test_abi_newtype::<[u32; 2]>();
85+
test_abi_newtype::<[u32; 32]>();
8286
}

0 commit comments

Comments
 (0)