-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[region-isolation] Add support for transferring parameters. #70836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci smoke test |
@swift-ci smoke test |
5f1b488
to
f623b4e
Compare
@swift-ci smoke test |
(just rebasing/retesting since I am back from vacation) |
Looks like the windows/macOS failures are related to swiftpm |
@swift-ci smoke test |
…a transferring OwnershipSpecifier.
NOTE: This does not handle yet assignment into transferring parameters. In the next commit, I am going to teach the checker that assigning into such a parameter is a transfer.
…ferring parameter is a transfer of the value. The specific semantics is if we assign into a transferring parameter's field, then we "merge" src's value into the transferring parameter, so we conservatively leave the region of the transferring parameter alone. If we assign over the entire transferring parameter, we perform an assign fresh since any value that used to be in the transferring parameter cannot reference anything in its new value since they are all gone.
…d optionals. llvm::Optional<T> used to make it so that in asserts builds if one dereferenced the optional and nothing was there, one would get an assert. std::optional<T> does not have that property.
…r being strongly transferred is an error. Before the previous patch, we were just getting lucky on macOS due to UB. Now that the UB is fixed, we correctly crash without this commit since we were not pattern matching the simple case of a local value that was transferred and used later.
c50e171
to
eb57309
Compare
@swift-ci smoke test |
I got feedback from some people about some small changes about loosening the rules around assigning into a transferring parameter. I am going to do that in a follow on commit. This at least gets in the basics and ensures that I do not hit more merge conflicts around Serialization. |
A transferring parameter is a consuming like param modifier that can be used to transfer values to an async function such that you can transfer the value further.
Since it is consuming, one can assign into it. When one assigns into it, one has transferred the new value into the transferred parameter.