]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/function_calls/exported_symbol_abi_mismatch.rs
Rollup merge of #101189 - daxpedda:ready-into-inner, r=joshtriplett
[rust.git] / src / tools / miri / tests / fail / function_calls / exported_symbol_abi_mismatch.rs
1 //@revisions: no_cache cache fn_ptr
2
3 #[no_mangle]
4 fn foo() {}
5
6 fn main() {
7     #[cfg(any(cache, fn_ptr))]
8     extern "Rust" {
9         fn foo();
10     }
11
12     #[cfg(fn_ptr)]
13     unsafe {
14         std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
15         //[fn_ptr]~^ ERROR: calling a function with calling convention Rust using calling convention C
16     }
17
18     // `Instance` caching should not suppress ABI check.
19     #[cfg(cache)]
20     unsafe {
21         foo();
22     }
23
24     {
25         #[cfg_attr(any(cache, fn_ptr), allow(clashing_extern_declarations))]
26         extern "C" {
27             fn foo();
28         }
29         unsafe {
30             foo();
31             //[no_cache]~^ ERROR: calling a function with calling convention Rust using calling convention C
32             //[cache]~| ERROR: calling a function with calling convention Rust using calling convention C
33         }
34     }
35 }