Skip to content

Commit b361148

Browse files
tests: migrate unsupported-abi-transmute.rs to extern "rust-invalid"
1 parent a780e84 commit b361148

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
//@ add-core-stubs
2-
//@ compile-flags: --crate-type=lib --target x86_64-unknown-none
3-
//@ needs-llvm-components: x86
1+
// Check we error before unsupported ABIs reach codegen stages.
2+
43
//@ edition: 2018
5-
#![no_core]
6-
#![feature(no_core, lang_items)]
7-
extern crate minicore;
8-
use minicore::*;
4+
//@ compile-flags: --crate-type=lib
5+
#![feature(rustc_attrs)]
96

10-
// Check we error before unsupported ABIs reach codegen stages.
7+
use core::mem;
118

129
fn anything() {
13-
let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
10+
let a = unsafe { mem::transmute::<usize, extern "rust-invalid" fn(i32)>(4) }(2);
1411
//~^ ERROR: is not a supported ABI for the current target [E0570]
1512
}

tests/ui/abi/unsupported-abi-transmute.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0570]: "thiscall" is not a supported ABI for the current target
2-
--> $DIR/unsupported-abi-transmute.rs:13:53
1+
error[E0570]: "invalid" is not a supported ABI for the current target
2+
--> $DIR/unsupported-abi-transmute.rs:10:53
33
|
4-
LL | let a = unsafe { mem::transmute::<usize, extern "thiscall" fn(i32)>(4) }(2);
5-
| ^^^^^^^^^^
4+
LL | let a = unsafe { mem::transmute::<usize, extern "invalid" fn(i32)>(4) }(2);
5+
| ^^^^^^^^^
66

77
error: aborting due to 1 previous error
88

tests/ui/abi/unsupported-in-impls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Test for https://github.com/rust-lang/rust/issues/86232
22
// Due to AST-to-HIR lowering nuances, we used to allow unsupported ABIs to "leak" into the HIR
33
// without being checked, as we would check after generating the ExternAbi.
4+
// Checking afterwards only works if we examine every HIR construct that contains an ExternAbi,
5+
// and those may be very different in HIR, even if they read the same in source.
6+
// This made it very easy to make mistakes.
47
//
58
// Here we test that an unsupported ABI in various impl-related positions will be rejected,
69
// both in the original declarations and the actual implementations.

0 commit comments

Comments
 (0)