-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[move-only] Implement escaping closure semantics part 1 #63783
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…gerly projected box form. This is the first slice of bringing up escaping closure support. The support is based around introducing a new type of SILGen VarLoc: a VarLoc with a box and without a value. Because the VarLoc only has a box, we have to in SILGen always eagerly reproject out the address from the box. The reason why I am doing this is that it makes it easy for the move checker to distinguish in between different accesses to the box that we want to check separately. As such every time that we open the box, we insert a mark_must_check [assignable_but_not_consumable] on that project. If allocbox_to_stack manages to determine that the box can be stack allocated, we eliminate all of the mark_must_check and place a new mark_must_check [consumable_and_assignable] on the alloc_stack. The end result is that we get the old model that we had before and also can support escaping closures.
Some notes: 1. This ensures that if we capture them, we just capture the box by reference. 2. We are still using the old incorrect semantics for captures. I am doing this so I can bring this up in separate easy to understand patches all of which pass all of the moveonly tests. 3. Most of the test edits are due to small differences in error messages in between the object and address checker. 4. I had to add a little support to the move only address checker for a small pattern that doesn't occur with vars but do es occur for lets when we codegen like this, specifically around enums. The pattern is we perform a load_borrow and then copy_value and then use the result of the copy_value. Rather than fight SILGen pattern I introduced a small canonicalization into the address checker which transforms that pattern into a load [copy] + begin_borrow to restore the codegen to a pattern the checker expects. 5. I left noimplicitcopy alone for now. But we should come back around and fix it in a similar way. I just did not have time to do so.
NOTE: A few of the test patterns need to be made better, but this patch series is large enough, I want to get it into tree and iterate.
@swift-ci smoke test |
jckarter
reviewed
Feb 20, 2023
jckarter
reviewed
Feb 20, 2023
Thanks to JoeG for seeing this quickly and preventing me from having to track this down!
…escaping closure since we will already emit a more specific capture error.
@swift-ci smoke test |
@swift-ci build toolchain |
Linux failure was unrelated problem in dispatch. |
@swift-ci smoke test linux platform |
Windows failed b/c I left in some optnone by mistake from when I was debugging |
@swift-ci smoke test |
@swift-ci build toolchain |
@swift-ci clean smoke test linux platform |
ludwwwig
added a commit
to ludwwwig/swift
that referenced
this pull request
May 3, 2025
This header was supposed to be deleted by swiftlang#63783.
ludwwwig
added a commit
to ludwwwig/swift
that referenced
this pull request
May 3, 2025
This header was supposed to be deleted by swiftlang#63783.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch series does a bunch of things:
This basically required me to rewrite a large part of SILGen for non copyable types and redesign parts of the checker as well. I also had to do a bunch of work in alloc box to stack to massage its output since it semantically is what controls whether we use non-escaping or escaping semantics when we emit these errors.