Skip to content

Commit 7632fab

Browse files
tests: Adopt ABI transmute tests from crashtests
1 parent 0dd29e1 commit 7632fab

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,
@@ -196,3 +197,9 @@ impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a
196197
trait Drop {
197198
fn drop(&mut self);
198199
}
200+
201+
pub mod mem {
202+
#[rustc_nounwind]
203+
#[rustc_intrinsic]
204+
pub unsafe fn transmute<Src, Dst>(src: Src) -> Dst;
205+
}

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)