Skip to content

Commit 067f1d3

Browse files
committed
SILGen: Don't mark_unresolved copyable borrows from noncopyable switches
1 parent 03e2e8f commit 067f1d3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,14 @@ void PatternMatchEmission::bindBorrow(Pattern *pattern, VarDecl *var,
13911391
assert(value.getFinalConsumption() == CastConsumptionKind::BorrowAlways);
13921392

13931393
auto bindValue = value.asBorrowedOperand2(SGF, pattern).getFinalManagedValue();
1394-
if (bindValue.getType().isObject()) {
1395-
// Create a notional copy for the borrow checker to use.
1396-
bindValue = bindValue.copy(SGF, pattern);
1394+
if (bindValue.getType().isMoveOnly()) {
1395+
if (bindValue.getType().isObject()) {
1396+
// Create a notional copy for the borrow checker to use.
1397+
bindValue = bindValue.copy(SGF, pattern);
1398+
}
1399+
bindValue = SGF.B.createMarkUnresolvedNonCopyableValueInst(pattern, bindValue,
1400+
MarkUnresolvedNonCopyableValueInst::CheckKind::NoConsumeOrAssign);
13971401
}
1398-
bindValue = SGF.B.createMarkUnresolvedNonCopyableValueInst(pattern, bindValue,
1399-
MarkUnresolvedNonCopyableValueInst::CheckKind::NoConsumeOrAssign);
1400-
14011402
SGF.VarLocs[var] = SILGenFunction::VarLoc::get(bindValue.getValue());
14021403
}
14031404

0 commit comments

Comments
 (0)