Documenting the case of Weak::upgrade returning None when the value behind the reference is missing#155049
Conversation
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| /// dropping of the inner value if successful. | ||
| /// | ||
| /// Returns [`None`] if the inner value has since been dropped. | ||
| /// Returns [`None`] if the inner value has since been dropped or moved out. |
There was a problem hiding this comment.
Technically, there is a third nightly-only case for Weak::upgrade returning None for Rc when the reference has been created by calling new_in, but I'm not sure how and whether it should be explicitely mentioned.
There was a problem hiding this comment.
new_in is the allocator_api analogue of the stable Weak::new, for which upgrade has the same behavior.
Maybe something like
Returns [
None] if the inner value has since been dropped or moved out, or if thisWeakdoes not point to an allocation.
There was a problem hiding this comment.
There's also the unstable case of a Weak created from UniqueRc::downgrade where the UniqueRc hasn't yet been turned into an Rc, for which the inner value hasn't been dropped or moved out, but something else currently owns it.
There was a problem hiding this comment.
@zachs18 updated the comment both for Rc and Arc.
There was a problem hiding this comment.
There's also the unstable case of a
Weakcreated fromUniqueRc::downgradewhere theUniqueRchasn't yet been turned into anRc, for which the inner value hasn't been dropped or moved out, but something else currently owns it.
I suppose the same goes for the upgrades from within the new_cyclic callback. Should it become a list at this point?
Returns [None] in the following cases:
- the inner value has since been dropped or moved out
- this
Weakdoes not point to an allocation- the owning reference this
Weakis assosiated with is either not fully constructed or does not allow an upgrade.
Weak::upgrade when the value behind the reference has been moved outWeak::upgrade returning None when the value behind the reference has been moved out
Weak::upgrade returning None when the value behind the reference has been moved outWeak::upgrade returning None when the value behind the reference is missing
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm not sure what tidy does not like now. |
|
You can run The specific issue here is that there is trailing whitespace on those lines. You can use You can also install a git hook so that git will error if you try to push code that fails tidy: https://rustc-dev-guide.rust-lang.org/building/suggested.html#installing-a-pre-push-hook |
|
@bors squash "Extended the documentation for Arc's Weak::upgrade" |
|
Unknown argument ""Extended". Did you mean to use |
|
@bors squash message="Extended the documentation for Arc's Weak::upgrade" |
This comment has been minimized.
This comment has been minimized.
|
🔨 7 commits were squashed into f580872. |
2c08481 to
f580872
Compare
|
@bors r+ rollup |
…uwer Rollup of 5 pull requests Successful merges: - #154781 (Fix attribute order implementation) - #155242 (resolve: Introduce `(Local,Extern)Module` newtypes for local and external modules respectively) - #149614 (Use `MaybeDangling` in `std`) - #153178 (Add `TryFromIntError::kind` method and `IntErrorKind::NotAPowerOfTwo` variant) - #155049 (Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing) Failed merges: - #155308 (Make `OnDuplicate::Error` the default for attributes)
…uwer Rollup of 5 pull requests Successful merges: - #154781 (Fix attribute order implementation) - #155242 (resolve: Introduce `(Local,Extern)Module` newtypes for local and external modules respectively) - #149614 (Use `MaybeDangling` in `std`) - #153178 (Add `TryFromIntError::kind` method and `IntErrorKind::NotAPowerOfTwo` variant) - #155049 (Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing) Failed merges: - #155308 (Make `OnDuplicate::Error` the default for attributes)
Rollup merge of #155049 - quixoticaxis:weak-upgrade-documentation-extension, r=jhpratt Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing Adds a clause to the documentation of `Weak` for `Arc` which was discussed in #154936. Adds the same clause to the documentation of `Weak` for `Rc`, because the behavior is the same.
Adds a clause to the documentation of
WeakforArcwhich was discussed in #154936.Adds the same clause to the documentation of
WeakforRc, because the behavior is the same.