mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[MoveChecker] Ban exported partial consumption.
To avoid dialecticization based on compilation mode, ban for non-resilient modules partial consumption of aggregates which would be illegal were those modules instead resilient.
This commit is contained in:
@@ -834,12 +834,53 @@ void DiagnosticEmitter::emitCannotPartiallyMutateError(
|
||||
}();
|
||||
diagnose(astContext, user, diagnostic, varName);
|
||||
registerDiagnosticEmitted(address);
|
||||
auto deinitLoc = error.getNominal().getValueTypeDestructor()->getLoc(
|
||||
/*SerializedOK=*/false);
|
||||
auto deinitLoc =
|
||||
error.getDeinitingNominal().getValueTypeDestructor()->getLoc(
|
||||
/*SerializedOK=*/false);
|
||||
if (!deinitLoc)
|
||||
return;
|
||||
astContext.Diags.diagnose(deinitLoc, diag::sil_movechecking_deinit_here);
|
||||
return;
|
||||
}
|
||||
case PartialMutationError::Kind::NonfrozenImportedType: {
|
||||
assert(
|
||||
astContext.LangOpts.hasFeature(Feature::MoveOnlyPartialConsumption) ||
|
||||
astContext.LangOpts.hasFeature(
|
||||
Feature::MoveOnlyPartialReinitialization));
|
||||
auto &nominal = error.getNonfrozenImportedNominal();
|
||||
auto diagnostic = [&]() {
|
||||
switch (kind) {
|
||||
case PartialMutation::Kind::Consume:
|
||||
return diag::sil_movechecking_cannot_destructure_imported_nonfrozen;
|
||||
case PartialMutation::Kind::Reinit:
|
||||
return diag::sil_movechecking_cannot_partially_reinit_nonfrozen;
|
||||
}
|
||||
}();
|
||||
diagnose(astContext, user, diagnostic, varName,
|
||||
nominal.getDeclaredInterfaceType(), nominal.getModuleContext());
|
||||
registerDiagnosticEmitted(address);
|
||||
return;
|
||||
}
|
||||
case PartialMutationError::Kind::NonfrozenUsableFromInlineType: {
|
||||
assert(
|
||||
astContext.LangOpts.hasFeature(Feature::MoveOnlyPartialConsumption) ||
|
||||
astContext.LangOpts.hasFeature(
|
||||
Feature::MoveOnlyPartialReinitialization));
|
||||
auto &nominal = error.getNonfrozenUsableFromInlineNominal();
|
||||
auto diagnostic = [&]() {
|
||||
switch (kind) {
|
||||
case PartialMutation::Kind::Consume:
|
||||
return diag::
|
||||
sil_movechecking_cannot_destructure_exported_usableFromInline_alwaysEmitIntoClient;
|
||||
case PartialMutation::Kind::Reinit:
|
||||
return diag::
|
||||
sil_movechecking_cannot_partially_reinit_exported_usableFromInline_alwaysEmitIntoClient;
|
||||
}
|
||||
}();
|
||||
diagnose(astContext, user, diagnostic, varName,
|
||||
nominal.getDeclaredInterfaceType());
|
||||
registerDiagnosticEmitted(address);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user