Skip to content

Can't compare unsafe function pointers #13385

Closed
@jdm

Description

@jdm
type JSPropertyOp = extern "C" fn();
type JSPropertyOp2 = extern "C" unsafe fn();

extern fn foo() {
}

fn main() {
    let bar: JSPropertyOp = foo;
    if bar == foo {
    }

    let bar: JSPropertyOp2 = foo;
    if bar == foo {
    }
}

yields

[jdm@rosencrantz rust-mozjs]$ rustc /tmp/unsafe.rs 
/tmp/unsafe.rs:13:8: 13:18 error: binary operation `==` cannot be applied to type `extern "C" unsafe fn()`
/tmp/unsafe.rs:13     if bar == foo {
                         ^~~~~~~~~~
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions