Skip to content

Commit ca4c221

Browse files
authored
Merge pull request #26523 from rxwei/clarify-partial-apply-inout-aliasable
[Docs] Clarify partial_apply's ownership of @inout_aliasable arguments.
2 parents 9f90fb1 + ffa9c40 commit ca4c221

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

docs/SIL.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,13 +3484,14 @@ has an escaping function type (not ``[on_stack]``) the closure context will be
34843484
allocated with retain count 1 and initialized to contain the values ``%1``,
34853485
``%2``, etc. The closed-over values will not be retained; that must be done
34863486
separately before the ``partial_apply``. The closure does however take ownership
3487-
of the partially applied arguments; when the closure reference count reaches
3488-
zero, the contained values will be destroyed. If the ``partial_apply`` has a
3489-
``@noescape`` function type (``partial_apply [on_stack]``) the closure context
3490-
is allocated on the stack and initialized to contain the closed-over values. The
3491-
closed-over values are not retained, lifetime of the closed-over values must be
3492-
managed separately. The lifetime of the stack context of a ``partial_apply
3493-
[on_stack]`` must be terminated with a ``dealloc_stack``.
3487+
of the partially applied arguments (except for ``@inout_aliasable`` parameters);
3488+
when the closure reference count reaches zero, the contained values will be
3489+
destroyed. If the ``partial_apply`` has a ``@noescape`` function type
3490+
(``partial_apply [on_stack]``) the closure context is allocated on the stack and
3491+
initialized to contain the closed-over values. The closed-over values are not
3492+
retained, lifetime of the closed-over values must be managed separately. The
3493+
lifetime of the stack context of a ``partial_apply [on_stack]`` must be
3494+
terminated with a ``dealloc_stack``.
34943495

34953496
If the callee is generic, all of its generic parameters must be bound by the
34963497
given substitution list. The arguments are given with these generic
@@ -3499,6 +3500,11 @@ type with the given substitutions applied. The generic parameters themselves
34993500
cannot be partially applied; all of them must be bound. The result is always
35003501
a concrete function.
35013502

3503+
If an address argument has ``@inout_aliasable`` convention, the closure
3504+
obtained from ``partial_apply`` will not own its underlying value.
3505+
The ``@inout_aliasable`` parameter convention is used when a ``@noescape``
3506+
closure captures an ``inout`` argument.
3507+
35023508
TODO: The instruction, when applied to a generic function,
35033509
currently implicitly performs abstraction difference transformations enabled
35043510
by the given substitutions, such as promoting address-only arguments and returns

0 commit comments

Comments
 (0)