Skip to content

6.0: [MoveOnly] Call borrowing methods on existentials. #73895

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

nate-chandler
Copy link
Contributor

Explanation: Fix a diagnostic-on-valid in the move-checker.

Previously, calling a borrowing method on a non-copyable existential failed with error: usage of a noncopyable type that compiler can't verify. Here, this is fixed.

The move-only address-checker relies on switching on opcodes to determine what part of a value is used by an instruction. It uses a bitmap consisting of atoms which can each be consumed at most once. An existential is a single "atom" from that perspective. Here, the open_existential_addr opcode is treated as a pass-through. This makes sense because it produces an instance of an archetype which is also an "atom", and it's "the same" "atom".

Fixing the diagnostic exposed an issue in the existential specializer where it would create copies of non-copyable values when the argument was @in_guaranteed. The existential specializer is fixed to bail out to avoid such illegal copies.
Scope: Affects non-copyable code.
Issue: rdar://125864434
Original PR: #73857
Risk: Low. The fix is small and targeted.
Testing: Added regression test.
Reviewer: Andrew Trick ( @atrick )

It's a pass-through for FSPL's purposes.
Bail on non-consuming existential values which are move-only.
Existential specialization requires creating a copy in such cases and
that's illegal for move-only values.
@nate-chandler nate-chandler requested a review from a team as a code owner May 24, 2024 19:16
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler enabled auto-merge May 24, 2024 20:46
@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

@nate-chandler nate-chandler merged commit 2070648 into swiftlang:release/6.0 May 25, 2024
5 checks passed
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar125864434 branch May 25, 2024 23:34
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