File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 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
129fn 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}
Original file line number Diff line number Diff line change 1- error[E0570]: "thiscall " is not a supported ABI for the current target
2- --> $DIR/unsupported-abi-transmute.rs:13 :53
1+ error[E0570]: "rust-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 "rust-invalid " fn(i32)>(4) }(2);
5+ | ^^^^^^^^^^^^^^
66
77error: aborting due to 1 previous error
88
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments