Footgun with Rc::assume_init and related methods
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Location
I came across https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.assume_init recently, and spotted a footgun that I think ought to be called out:
Summary
The safety section does not clarify whether multiple Rcs are allowed to exist when assume_init is called. If they are, then whether Drop is called on the inner value will depend on the drop order of those Rcs. In the case of Arc this might well be non-deterministic.
IMO, the documentation should specify whether this is allowed, and if so should point out that callers must take care around this potential issue.
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 std::rc::Rc::assume_init documentation linked in the issue, then compare its safety section with related Rc and Arc methods. Done means the documentation clearly states whether multiple Rc or Arc values may exist at the call and explains the resulting Drop-order concern if applicable.
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
- 45/100