Fix DiagnoseStaticExclusivity for lifetime dependent sub-objects#88595
Open
atrick wants to merge 1 commit intoswiftlang:mainfrom
Open
Fix DiagnoseStaticExclusivity for lifetime dependent sub-objects#88595atrick wants to merge 1 commit intoswiftlang:mainfrom
atrick wants to merge 1 commit intoswiftlang:mainfrom
Conversation
Contributor
Author
|
@swift-ci test |
Contributor
Author
|
I tagged a bunch of potential reviewers here because it's an easy one-line fix and I'm not sure who has time to look at it. |
For example:
```
struct InoutPair: ~Escapable, ~Copyable {
@_lifetime(self: &x)
mutating func insertX(_ x: inout Int) {...}
@_lifetime(self: &y)
mutating func insertY(_ y: inout Int) {...}
}
struct Pair {
var x: Int
var y: Int
mutating func run() {
var inoutPair = InoutPair()
inoutPair.insertX(&x)
inoutPair.insertY(&y)
take(inoutPair) // The access of both &x and &y are extended up to here
}
}
```
In the `Pair.run` method, the accesses to &x and &y are overlapping because the
final value of `inoutPair` depends on both. Fix DiagnoseStaticExclusivity to
recognize that these accesses are to independent subobjects even though that
have a lifetime dependency.
Fixes rdar://175271283 ([exclusivity] handle simultaneous sub-object exclusivity
with lifetime dependencies)
80f23a5 to
014aef8
Compare
Contributor
Author
|
@swift-ci test |
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.
For example:
In the
Pair.runmethod, the accesses to &x and &y are overlapping because thefinal value of
inoutPairdepends on both. Fix DiagnoseStaticExclusivity torecognize that these accesses are to independent subobjects even though that
have a lifetime dependency.
Fixes rdar://175271283 ([exclusivity] handle simultaneous sub-object exclusivity
with lifetime dependencies)
We can consider a more robust design in the future:
rdar://175275018 ([nonescapable] create mark_dependence on the projection rather than the base)
But in the meantime, this problem basically makes it impossible to have dependencies on multiple sub-objects.