[allocbox-to-stack] When we promote an argument that is moveonly, use consumable_and_assignable, not assignable_but_not_consumable.

Otherwise, since the compiler views assignable_but_not_consumable in this
position as a sign of an escaping closure, we emit escaping closure errors
instead of nonescaping closure errors.
This commit is contained in:
Michael Gottesman
2023-05-11 13:05:56 -07:00
parent 3ccda34275
commit 9c9fe09e25

View File

@@ -1041,7 +1041,7 @@ specializeApplySite(SILOptFunctionBuilder &FuncBuilder, ApplySite Apply,
auto boxType = F->getArgument(index)->getType().castTo<SILBoxType>();
bool isMutable = boxType->getLayout()->getFields()[0].isMutable();
auto checkKind =
isMutable ? MarkMustCheckInst::CheckKind::AssignableButNotConsumable
isMutable ? MarkMustCheckInst::CheckKind::ConsumableAndAssignable
: MarkMustCheckInst::CheckKind::NoConsumeOrAssign;
hoistMarkMustCheckInsts(ClonedFn->getArgument(index), checkKind);
}