Rustonomicon and ManuallyDrop's documentation contradict each other about relying on drop order.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Location
https://doc.rust-lang.org/nomicon/dropck.html#a-related-side-note-about-drop-order
https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html#manuallydrop-and-drop-order
Summary
The Rustonomicon states:
While the drop order of fields inside a struct is defined, relying on it is fragile and subtle. When the order matters, it is better to use the
ManuallyDropwrapper.
The docs for ManuallyDrop states:
Rust has a well-defined drop order of values. To make sure that fields or locals are dropped in a specific order, reorder the declarations such that the implicit drop order is the correct one.
It is possible to use ManuallyDrop to control the drop order, but this requires unsafe code and is hard to do correctly in the presence of unwinding.
That is, when you rely on fields being dropped in a specific order, the Rustonomicon recommends using ManuallyDrop, while the ManuallyDrop documentation recommends using field ordering. Which of the two is correct?
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
Read the Rustonomicon dropck section, the ManuallyDrop documentation section, and the linked Reference destructors page. Determine the intended guidance on field ordering versus ManuallyDrop, then update the two cited documentation passages so they agree and verify the rendered links and wording.
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
- Mostly clear
- Newbie friendliness
- 42/100