Skip to content

Commit a969447

Browse files
committed
Update the free-standing function inference rules.
1 parent b6c51d8 commit a969447

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -673,14 +673,11 @@ If there is no explicit lifetime dependency, we will automatically infer one acc
673673
**For methods where the return value is nonescapable**, we will infer a dependency against self, depending on the mutation type of the function.
674674
Note that this is not affected by the presence, type, or modifier of any other arguments to the method.
675675

676-
**For a free or static functions or initializers with at least one argument,** we will infer a lifetime dependency when all of the following are true:
676+
**For a free or static functions or initializers with at least one argument,** we will infer a lifetime dependency when the return value is nonescapable and exactly one argument that satisfies any of the following:
677+
- is nonescapable, or
678+
- is non-BitwiseCopyable and has an explicit `borrowing`, or `inout` convention
677679

678-
* the return value is nonescapable,
679-
* there is exactly one argument that satisfies any of the following:
680-
- is either noncopyable or nonescapable, or
681-
- has an explicit `borrowing`, `consuming`, or `inout` convention specified
682-
683-
In this case, the compiler will infer a dependency on the unique argument identified by this last set of conditions.
680+
In this case, the compiler will infer a dependency on the unique argument identified by these conditions.
684681

685682
**In no other case** will a function, method, or initializer implicitly gain a lifetime dependency.
686683
If a function, method, or initializer has a nonescapable return value, does not have an explicit lifetime dependency annotation, and does not fall into one of the cases above, then that will be a compile-time error.

0 commit comments

Comments
 (0)