Fix lifetime dependence diagnostics on Void types.

Allow a dependence on Void to be considered immortal. This is the ultimate
override in cases where no other code pattern is supported yet.

(cherry picked from commit 36d2b5bee4)
This commit is contained in:
Andrew Trick
2025-06-23 00:33:57 -07:00
parent 04cb1a3c1e
commit 3dd1fb2518
2 changed files with 24 additions and 2 deletions

View File

@@ -199,9 +199,16 @@ private struct DiagnoseDependence {
if function.hasUnsafeNonEscapableResult {
return .continueWalk
}
// If the dependence scope is global, then it has immortal lifetime.
if case .global = dependence.scope {
// Check for immortal lifetime.
switch dependence.scope {
case .global:
return .continueWalk
case let .unknown(value):
if value.type.isVoid {
return .continueWalk
}
default:
break
}
// Check that the parameter dependence for this result is the same
// as the current dependence scope.