Align RwLockWriteGuard fields with the other RwLock guards (+ cleanup)#140018
Closed
connortsui20 wants to merge 1 commit intorust-lang:masterfrom
Closed
Align RwLockWriteGuard fields with the other RwLock guards (+ cleanup)#140018connortsui20 wants to merge 1 commit intorust-lang:masterfrom
RwLockWriteGuard fields with the other RwLock guards (+ cleanup)#140018connortsui20 wants to merge 1 commit intorust-lang:masterfrom
Conversation
Collaborator
Contributor
Author
|
r? @tgross35 |
Contributor
|
Joboet probably actually would have been a better reviewer for this than me, as the author of some of the implementations here. But it seems like we should hold off on changes until a sound API for upgrade is figured out, based on discussion at the ACP / tracking issue. @rustbot blocked |
Collaborator
|
☔ The latest upstream changes (presumably #140596) made this pull request unmergeable. Please resolve the merge conflicts. |
c6cceec to
9d6af91
Compare
This commit does a few things: - Unify the lifetime annotations to all use `'rwlock` where some where using `'a` - Unify the implementation blocks for the 4 different kinds of guards - Adds documentation to the fields of each struct - Aligns the fields of `RwLockWriteGuard` to be similar to the other 3 rename try_map to filter_map
9d6af91 to
d06d4b8
Compare
Contributor
Author
|
Closing in favor of #144175 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking Issue: #138559
Relevant comment: #138559 (comment)
Summary
This PR does a few things as setup for the implementation of
try_upgradeonRwLock. They are mostly cosmetic changes.'rwlockinstead of using'apoisonfields topoison_guard(if this change makes sense, we should also rename thepoisonfield inMutexGuard)RwLockWriteGuardto be similar to the other 3 guardsChanges
The only non-cosmetic change here is the last point, in which the fields of
RwLockWriteGuardare different.As a TLDR for #138559 (comment), if we want to convert a
RwLockReadGuardinto aRwLockWriteGuardsafely (as we will need to fortry_upgrade), I'm pretty sure we need to make the fields the same otherwise we have to do some nasty transmuting. Note it is very possible that I could be wrong on this.Concerns
I do have a concern over the
noaliascomment that I essentially copied and pasted from the docs forMappedRwLockWriteGuard. Is it really true that making the data fieldNonNullhere avoidsnoaliasLLVM violations in the exclusive / unique setting? This description makes sense for the read variants of the guards, but I'm having trouble wrapping my head around the logic for the write variants.I am also somewhat concerned because
MutexGuardonly stores a reference whileMappedMutexGuardstores a pointer.The only reason I have it here is because
MappedRwLockWriteGuardwas merged in #117107. CC'ing @zachs18 since he wrote that PR.