YaLTeR · GitHub

extern "fastcall", "system", "cdecl" and some others function pointers cannot be compared.

I tried this code:

https://is.gd/5JBZee

extern "fastcall" fn test() {}
fn main() {
    let fastcall_ptr: extern "fastcall" fn() = test;
    let check = fastcall_ptr == test;
}

I expected to see this happen: the code compiles fine.

Instead, this happened:

error[E0369]: binary operation `==` cannot be applied to type `extern "fastcall" fn()`
note: an implementation of `std::cmp::PartialEq` might be missing for `extern "fastcall" fn()`
error[E0308]: mismatched types
    expected fn pointer, found fn item

Replacing fastcall with C in this example, or getting rid of extern "fastcall" entirely results in code that compiles fine:

https://is.gd/JI89Zs

fn test() {}
extern "C" fn c_test() {}
fn main() {
    let ptr: fn() = test;
    let c_ptr: extern "C" fn() = c_test;
    let check = ptr == test;
    let c_check = c_ptr == c_test;
}

rustc 1.16.0-nightly ( 4682271 2017-01-03)

Read the original on github.com ↗