rust-lang / rust-lang/rust

Function pointers are not VaArgSafe

Open
#153,646 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-coherence C-discussion F-c_variadic T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The VaArgSafe trait is not implemented for fn types -- and fixing that seems non-trivial? There is no easy way to "implement a trait for all function pointers". This is something we may have to figure out before stabilizing https://github.com/rust-lang/rust/issues/44930 because surely we want to support fn types eventually and so we should be confident that the design we stabilize can accommodate that.

We do have the FnPtr trait, but wouldn't we risk coherence issues if we add something like this?

impl<T: FnPtr> VaArgSafe for T {}

Cc @folkertdev

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked tracking issue #44930 and the FnPtr trait documentation, then review the VaArgSafe and function-pointer design discussed there. Done means identifying a design that supports fn types without unresolved coherence issues and can be considered for stabilization.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.