rust-lang / rust-lang/reference
Document behavior of wide to thin pointer casts for DSTs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
Related #66, rust-lang/rust#81513
The following casts are considered "true casts" per the reference:
*const [T] as *const U*const dyn T as *const U
Today they are implemented so that the data pointer is returned and metadata discarded. However, this behavior does not appear to be documented anywhere authoritative.
In the rfc to ptr_metadata (Tracking issue: rust-lang/rust#81513) the following text was proposed, but as of today hasn't made it into the unstable Pointee trait:
Pointer metadata can be extracted from a pointer or reference with the
metadatafunction. The data pointer can be extracted by casting a (fat) pointer to a (thin) pointer to aSizedtype with theasoperator, for example(x: &dyn SomeTrait) as *const SomeTrait as *const ()or(x: *const dyn SomeTrait).cast::<()>().
Should this be documented in the reference or is the semantics contentious?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Reference's type cast expressions section and compare its treatment of wide-to-thin pointer casts with the linked RFC's reference-level explanation and tracking issues #66 and rust-lang/rust#81513. Confirm whether the data-pointer and metadata-discarding behavior is settled; done means documenting the agreed semantics in the authoritative Reference location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100