rust-lang / rust-lang/reference

The reference makes guarantees about "stack memory" that do not reflect our op.sem

Open
#1,489 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://doc.rust-lang.org/reference/variables.html says that "A local variable (or stack-local allocation) holds a value directly, allocated within the stack's memory." However, on the level of the Abstract Machine, there is no such thing as "the stack's memory". All allocated objects are placed at arbitrary locations in memory and there is no guarantee whatsoever that stack allocations are in "the stack" or Box allocations are on "the heap".

For instance, many local variables end up not having any actual memory allocated anywhere as they are entirely turned into registers.

The wording in the reference should be adjusted to avoid claims that cannot be held up by the Abstract Machine.

Thanks to @tautschnig for pointing this out.

Cc @rust-lang/opsem

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 with reference/variables.html and the quoted paragraph, then review the linked unsafe-code-guidelines discussion for the Abstract Machine concern. Done when the Reference no longer makes unsupported claims about physical stack or heap placement while still accurately describing local variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.