Skip to content

Commit 44f6ce3

Browse files
tests: Adopt ABI transmute tests from crashtests
1 parent 95578fa commit 44f6ce3

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

tests/auxiliary/minicore.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#![feature(
1818
no_core,
19+
intrinsics,
1920
lang_items,
2021
auto_traits,
2122
freeze_impls,
@@ -190,3 +191,9 @@ impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b
190191
trait Drop {
191192
fn drop(&mut self);
192193
}
194+
195+
pub mod mem {
196+
#[rustc_nounwind]
197+
#[rustc_intrinsic]
198+
pub unsafe fn transmute<Src, Dst>(src: Src) -> Dst;
199+
}

tests/crashes/138738.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ add-core-stubs
2+
//@ compile-flags: --crate-type=lib --target x86_64-unknown-none
3+
//@ needs-llvm-components: x86
4+
//@ edition: 2018
5+
#![no_core]
6+
#![feature(no_core, lang_items)]
7+
extern crate minicore;
8+
use minicore::*;
9+
10+
// Check we error before unsupported ABIs reach codegen stages.
11+
12+
fn anything() {
13+
let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
14+
//~^ ERROR: is not a supported ABI for the current target [E0570]
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0570]: "thiscall" is not a supported ABI for the current target
2+
--> $DIR/unsupported-abi-transmute.rs:13:53
3+
|
4+
LL | let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
5+
| ^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0570`.

0 commit comments

Comments
 (0)