tests: Adopt ABI transmute tests from crashtests

This commit is contained in:
Jubilee Young 2025-06-01 15:20:27 -07:00
parent 0dd29e1a86
commit 7632fab668
4 changed files with 31 additions and 7 deletions

View file

@ -16,6 +16,7 @@
#![feature(
no_core,
intrinsics,
lang_items,
auto_traits,
freeze_impls,
@ -196,3 +197,9 @@ impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a
trait Drop {
fn drop(&mut self);
}
pub mod mem {
#[rustc_nounwind]
#[rustc_intrinsic]
pub unsafe fn transmute<Src, Dst>(src: Src) -> Dst;
}

View file

@ -1,7 +0,0 @@
//@ known-bug: #138738
//@ only-x86_64
#![feature(abi_ptx)]
fn main() {
let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2);
}

View file

@ -0,0 +1,15 @@
//@ add-core-stubs
//@ compile-flags: --crate-type=lib --target x86_64-unknown-none
//@ needs-llvm-components: x86
//@ edition: 2018
#![no_core]
#![feature(no_core, lang_items)]
extern crate minicore;
use minicore::*;
// Check we error before unsupported ABIs reach codegen stages.
fn anything() {
let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
//~^ ERROR: is not a supported ABI for the current target [E0570]
}

View file

@ -0,0 +1,9 @@
error[E0570]: "thiscall" is not a supported ABI for the current target
--> $DIR/unsupported-abi-transmute.rs:13:53
|
LL | let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
| ^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0570`.