[6.2] Fix LifetimeDependenceDiagnostics: allow inout assignment to Void. #82832
+27
−0
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.
Bypess lifetime dependence diagnostics completely for immortal values. We did
not do this initially because we wanted to potentially consider a value with a missing
dependency to mean that it could not escape the current function. But now we use
Void
as a stand-in for immortal values.This is needed for reassigning a Span/MutableSpan to an empty, immortal
Span:
Fixes rdar://152572002 ([GH:#81976] Cannot reinitialize inout parameter of type
MutableSpan<T>?
)(cherry picked from commit ac94d7d)
--- CCC ---
Explanation: Fix lifetime diagnostics to allow assigning an immortal value to an inout parameter.
Scope: This only affects adopters of experimental but supported @_lifetime syntax. The following example would incorrectly report a lifetime error:
Radar/SR Issue: rdar://152572002 ([GH:#81976] Cannot reinitialize inout parameter of type
MutableSpan<T>?
)main PR: #82831
Risk: Low. No new logic is introduced. The existing check for immortal values is moved earlier to handle inout parameters as well as return value. The risk is that diagnostics are less restrictive.
Testing: Added source-level unit test.
Reviewer: TBD