rust-lang / rust-lang/reference

'Type layout' and 'Dynamically Sized Types' pages disagree on whether the size of a pointer to a DST is defined

Open
#1,303 3 comments 0 reactions 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

The 'Dynamically Sized Types' page pretty clearly states that the size of a pointer to a DST is twice the size of a regular pointer:

  • Pointer types to DSTs are sized but have twice the size of pointers to sized types

But, the 'Type layout' page gives this much less concrete answer:

  • Pointers to unsized types are sized. The size and alignment is guaranteed to be at least equal to the size and alignment of a pointer.

And, in a note, it says the same thing as the DST page, but says that it shouldn't be relied upon:

Note: Though you should not rely on this, all pointers to DSTs are currently twice the size of the size of usize and have the same alignment.

The two pages should be consistent. Assuming that the DST page is correct, the type layout page should also concretely say that pointers to unsized types are twice the size of regular pointers, and the note should be removed.

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

Compare the pointer-layout sections in reference/src/types/dynamically-sized-types.md and reference/src/type-layout.md, following the links in the issue. Check the surrounding Reference wording and existing documentation tests or checks first. Done means both pages give consistent, explicit guidance about pointers to dynamically sized types and no contradictory note remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.