Skip to content

unpredictable_function_pointer_comparisons doesn't lint against Option<fn()> #134527

Closed
@kornelski

Description

@kornelski

In C FFI it's very common to use Option<fn()> for callbacks, but the lint #118833 doesn't fire when Options of function pointers are compared:

unsafe extern "C" fn func() {}

type FnPtr = unsafe extern "C" fn();

fn main() {
    assert_eq!(Some::<FnPtr>(func), Some(func as unsafe extern "C" fn()));
}

This pattern is used in: https://github.com/ImageOptim/mozjpeg-rust/blob/cff5aad77c726c11f460baefc348c7279d0ee647/src/readsrc.rs#L136

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions