Align RwLockWriteGuard fields with the other RwLock guards (+ cleanup)
#140018
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.