swift
361aa81d - [move-only-address] Now that we borrow move only types when we call functions, enable the main move only address transform.

Commit
2 years ago
[move-only-address] Now that we borrow move only types when we call functions, enable the main move only address transform. The main constraint that we needed to fight here is that we are not allowed in the move only address checker to expand exclusivity scopes since we run after the main exclusivity passes. This means that to enable this transformation I needed to add a new error diagnostic that is emitted if we are unable to convert a loadCopyOrTake operation to a borrow like operation due to an exclusivity scope that is too tight. Example: ``` %0 = begin_access [read] %addr %1 = load [copy] %0 end_access %0 ... destroy_value %1 ``` Luckily this does not actually happen for move only structs/move only enums after 525ba8c07bf2a48fc104a6589e0d007ec4da8a69 which makes it so that we perform a true borrow of those types when passing them to functions. If we pass a move only class directly, we get the same behavior. Sadly if we pass a field from a move only class, we still get a tight exclusivity scope and thus will emit an error today. This is an issue that we can fight at a later time once we decide to productize move only classes further. But at least structs/enums work well. One can see this behavior by looking at all of the places that needed to be updated as a result of this change. rdar://102491093
Author
Committer
Parents
Loading