Skip to content

Impls for function pointers are patchy #26082

Closed
@petrochenkov

Description

@petrochenkov

I'd expect function pointers (fn() with all combinations of safety and ABI) to implement roughly the same set of traits as raw pointers, namely:
PartialEq, Eq, Clone, PartialOrd, Ord, Hash, fmt::Pointer, Debug

Currently Clone is implemented for safe and unsafe function pointers, but all the ABIs except for "Rust" and "C" are ignored, i.e. a paradoxical situation takes place - extern "rare_abi" fn() is Copy, but not Clone (Edit: and it causes ICEs).
PartialEq is implemented only for safe function pointers with "C" ABI.
All the other traits are not implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions