Skip to main content

## UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS

# Static UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS

Source

    static UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS: &Lint

Expand description

The `unpredictable_function_pointer_comparisons` lint checks comparison of function pointer as the operands.

#### §Example

    fn a() {}
    fn b() {}

    let f: fn() = a;
    let g: fn() = b;

    let _ = f == g;

{{produces}}

#### §Explanation

Function pointers comparisons do not produce meaningful result since they are never guaranteed to be unique and could vary between different code generation units. Furthermore, different functions could have the same address after being merged together.