I'm going to be honest with you, I am not sure.
But here are my thoughts;
extern "Rust" fn()
Has the Rust
abi, and similarly,
unsafe extern "Rust" fn()
also has the Rust
abi (note that these are identical to not having the extern "Rust"
modifier).
Now, I don't believe that Rust makes any guarantees about its ABI, so it's possible that it could be different for unsafe/safe variants of the functions.
However
C doesn't have a notion of unsafe/safe functions, and so I would have to assume that the following two type signatures are equivalent, abi-wise:
type Safe = extern "C" fn();
type Unsafe = unsafe extern "C" fn();
And, therefore, the following should be okay:
extern "C" fn foo() {}
let safe_fn = foo as fn();
let unsafe_fn = unsafe {
let pointer = &safe_fn as *const extern "C" fn();
*(reference as *const unsafe extern "C" fn())
};
However, I believe someone better acquainted with the internals of Rust would be able to better answer the question at hand.