Skip to content

Commit ecff956

Browse files
committed
Auto merge of #3046 - RalfJung:rustup, r=RalfJung
Rustup also more ABI compat tests
2 parents 09b78f3 + 7c7219c commit ecff956

18 files changed

+160
-19
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
008c21c9779fd1e3632d9fe908b8afc0c421b26c
1+
dca2d1ff00bf96d244b1bb9a2117a92ec50ac71d
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(portable_simd)]
2+
3+
// Some targets treat arrays and structs very differently. We would probably catch that on those
4+
// targets since we check the `PassMode`; here we ensure that we catch it on *all* targets
5+
// (in particular, on x86-64 the pass mode is `Indirect` for both of these).
6+
struct S(i32, i32, i32, i32);
7+
type A = [i32; 4];
8+
9+
fn main() {
10+
fn f(_: S) {}
11+
12+
// These two types have the same size but are still not compatible.
13+
let g = unsafe { std::mem::transmute::<fn(S), fn(A)>(f) };
14+
15+
g(Default::default()) //~ ERROR: calling a function with argument of type S passing data of type [i32; 4]
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: calling a function with argument of type S passing data of type [i32; 4]
2+
--> $DIR/abi_mismatch_array_vs_struct.rs:LL:CC
3+
|
4+
LL | g(Default::default())
5+
| ^^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type S passing data of type [i32; 4]
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/abi_mismatch_array_vs_struct.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
fn f(_: f32) {}
3+
4+
let g = unsafe { std::mem::transmute::<fn(f32), fn(i32)>(f) };
5+
6+
g(42) //~ ERROR: calling a function with argument of type f32 passing data of type i32
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: calling a function with argument of type f32 passing data of type i32
2+
--> $DIR/abi_mismatch_int_vs_float.rs:LL:CC
3+
|
4+
LL | g(42)
5+
| ^^^^^ calling a function with argument of type f32 passing data of type i32
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/abi_mismatch_int_vs_float.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

tests/fail/function_pointers/cast_fn_ptr4.stderr renamed to tests/fail/function_pointers/abi_mismatch_raw_pointer.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with argument of type *const [i32] passing data of type *const i32
2-
--> $DIR/cast_fn_ptr4.rs:LL:CC
2+
--> $DIR/abi_mismatch_raw_pointer.rs:LL:CC
33
|
44
LL | g(&42 as *const i32)
55
| ^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type *const [i32] passing data of type *const i32
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr4.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_raw_pointer.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

tests/fail/function_pointers/cast_fn_ptr5.stderr renamed to tests/fail/function_pointers/abi_mismatch_return_type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with return type u32 passing return place of type ()
2-
--> $DIR/cast_fn_ptr5.rs:LL:CC
2+
--> $DIR/abi_mismatch_return_type.rs:LL:CC
33
|
44
LL | g()
55
| ^^^ calling a function with return type u32 passing return place of type ()
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr5.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_return_type.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

0 commit comments

Comments
 (0)