Skip to content

Fix LifetimeDependenceDiagnostics: allow inout assignment to Void. #82831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jul 7, 2025

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:

func inoutToImmortal(_ s: inout RawSpan) {
  let tmp = RawSpan(_unsafeBytes: UnsafeRawBufferPointer(start: nil, count: 0))
  s = _overrideLifetime(tmp, borrowing: ())
}

Fixes rdar://152572002 ([GH:#81976] Cannot reinitialize inout parameter of type
MutableSpan<T>?)

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:

    func inoutToImmortal(_ s: inout RawSpan) {
      let tmp = RawSpan(_unsafeBytes: UnsafeRawBufferPointer(start: nil, count: 0))
      s = _overrideLifetime(tmp, borrowing: ())
    }

Fixes rdar://152572002 ([GH:swiftlang#81976] Cannot reinitialize inout parameter of type
`MutableSpan<T>?`)
@atrick atrick requested a review from eeckstein as a code owner July 7, 2025 07:17
@atrick
Copy link
Contributor Author

atrick commented Jul 7, 2025

@swift-ci test

@atrick atrick enabled auto-merge July 7, 2025 07:21
@atrick atrick requested a review from meg-gupta July 7, 2025 07:21
@atrick
Copy link
Contributor Author

atrick commented Jul 7, 2025

@swift-ci smoke test macOS

@atrick
Copy link
Contributor Author

atrick commented Jul 7, 2025

@swift-ci smoke test macOS

@atrick
Copy link
Contributor Author

atrick commented Jul 7, 2025

three time-outs in a row building LLVM
Running on macos-node-i-069f137eeee82f9c8

@atrick
Copy link
Contributor Author

atrick commented Jul 7, 2025

@swift-ci smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant