6.0: [MoveOnly] Call borrowing methods on existentials. #73895
Merged
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.
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 )