Skip to content

[move-only] Some fixes around closures. #65694

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 5 commits into from
May 5, 2023
Merged

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented May 5, 2023

Just beginning testing I am going to file this out further in the morning

gottesmm added 5 commits May 4, 2023 12:25
…as such even if the closure doesn't actually escape

Specifically, we already have the appropriate semantics for arguments captured
by escaping closures but in certain cases allocbox to stack is able to prove
that the closure doesn’t actually escape. This results in the capture being
converted into a non-escaping SIL form. This then causes the move checker to
emit the wrong kind of error.

The solution is to create an early allocbox to stack that doesn’t promote move
only types in boxes from heap -> stack if it is captured by an escaping closure
but does everything else normally. Then once the move checking is completed, we
run alloc box to stack an additional time to ensure that we keep the guarantee
that heap -> stack is performed in those cases.

rdar://108905586
…ng non-consuming uses appropriately. We are doing so now.
…ble twice. We are no longer doing that in the specific test.
Specifically:

1. I added consuming test cases alongside __owned test cases.

2. I inserted the actual error messages so that we can see if we are emitting
   the correct error messages.

3. I enabled the NONTRIVIAL and NONTRIVIAL/REABSTRACT variants of the tests.

There are some differences in the address only version of the test that I am
still looking into.
…ther local, emit the correct error message.

With some of the changes that I have made, we began to emit a mark_must_check
[no_copy] on a copy_addr here. This change teaches the move address checker how
to recognize that in this case if we have a project_box it is actually b/c we
have something captured by an escaping closure.
@gottesmm
Copy link
Contributor Author

gottesmm commented May 5, 2023

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented May 5, 2023

@swift-ci test windows platform

@gottesmm gottesmm requested a review from jckarter May 5, 2023 16:29
@gottesmm gottesmm merged commit 9198a8a into swiftlang:main May 5, 2023
@gottesmm gottesmm deleted the closurestuff branch May 5, 2023 17:17
@kavon kavon self-requested a review May 5, 2023 18:40
Copy link
Member

@kavon kavon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants