rust-lang / rust-lang/reference

Explain what the `fn` is an "ABI" and what equivalencies we guarantee

Open
#1,623 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-abi
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

Documentation for this is sort of awkwardly scattered around std docs, the Reference, the Rustonomicon, and the UCG (some of which is more aspirational than actual, for note!), we should sit down and actually document it all somewhere. Probably a new or massively-expanded section of the Reference.

Some notes on major things to make sure we've gotten down into roughly the same place:

  • Explain the difference between repr(Rust) and extern "Rust" or repr(C) and extern "C"
  • Explain how Rust ABI strings relate to commonly-described ABI (e.g. "C" vs. "C-unwind")
  • Explain that memory layout is important to, but not sufficient for, matching function-call ABI
  • Explain that extern "C" has a target-specific meaning based on a psABI and how it is interpreted by the compilers, not specified by "Standard C"
  • Document the special-case guarantees for some types:
    • Option<T>
    • Result<T, Zst>
    • Result<Zst, T>
    • bool
  • Explain the ABI-mismatch UB cases
    • Document any major "unguarantees" (reservations?)
  • Do we have to mention #[target_feature]?
  • Explain that there are not-immediately-arg/ret-related esoterica about ABI
    • mention stack alignment
    • mention MXCSR or FPCSR state
    • mention unwinding / destructors

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 comparing the scattered material in the standard library documentation, the Reference, the Rustonomicon, and the linked UCG. A new or substantially expanded Reference section is done when it consolidates the listed ABI distinctions, guarantees, mismatch UB cases, target-specific behavior, and related ABI details.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.