1 #![feature(rustc_attrs)]
4 extern "C" fn foo() -> i32 {
13 #[rustc_std_internal_symbol]
29 // Repeat calls to make sure the `Instance` cache is not broken.
33 fn free(_: *mut std::ffi::c_void);
36 assert_eq!(unsafe { foo() }, -1);
38 // `free()` is a built-in shim, so calling it will add ("free", None) to the cache.
39 // Test that the cache is not broken with ("free", None).
40 unsafe { free(std::ptr::null_mut()) }
48 assert_eq!(unsafe { bar() }, -2);
49 assert_eq!(unsafe { baz() }, -3);
50 assert_eq!(unsafe { qux() }, -4);
52 #[allow(clashing_extern_declarations)]
60 std::mem::transmute::<unsafe fn() -> i32, unsafe extern "C" fn() -> i32>(foo)()
73 std::mem::transmute::<unsafe extern "C" fn() -> i32, unsafe fn() -> i32>(f)
75 assert_eq!(transmute(bar)(), -2);
76 assert_eq!(transmute(baz)(), -3);
77 assert_eq!(transmute(qux)(), -4);