Lifetime inference: restructure to support multiple dependencies.

Restructure the inference logic to allow the same function declaration to
independently annotate or infer different lifetime targets.

For example:

   @_lifetime(borrow a)
   /* DEFAULT: @_lifetime(b: copy b)
   func f(a: A, b: inout B) -> NE

The fact that we prevented this was somewhat accidental and surprising.

This restructuring simplifies the code but also gives us much more control over
the inference logic.

Fixes: rdar://159288750 ("A function cannot have a ~Escapable 'inout' parameter
in addition to other ~Escapable parameters" is not actionable)
This commit is contained in:
Andrew Trick
2025-08-25 10:28:08 -07:00
parent d8cbb57304
commit ada46a0cf0
2 changed files with 645 additions and 604 deletions

View File

@@ -218,7 +218,7 @@ public:
addressableParamIndicesAndImmortal(addressableParamIndices, isImmortal),
conditionallyAddressableParamIndices(conditionallyAddressableParamIndices),
targetIndex(targetIndex) {
assert(this->isImmortal() || inheritLifetimeParamIndices ||
ASSERT(this->isImmortal() || inheritLifetimeParamIndices ||
scopeLifetimeParamIndices);
ASSERT(!inheritLifetimeParamIndices ||
!inheritLifetimeParamIndices->isEmpty());