ManualOwnership: introduce 'SemanticCopies' diagnostic group

This includes documentation to explain how to understand
these diagnostics.
This commit is contained in:
Kavon Farvardin
2025-10-12 16:46:17 -07:00
parent 7e8d8b671f
commit 95a6719117
4 changed files with 10 additions and 5 deletions

View File

@@ -73,6 +73,7 @@ GROUP(ProtocolTypeNonConformance, "protocol-type-non-conformance")
GROUP(RegionIsolation, "region-isolation")
GROUP(ResultBuilderMethods, "result-builder-methods")
GROUP(ReturnTypeImplicitCopy, "return-type-implicit-copy")
GROUP(SemanticCopies, "semantic-copies")
GROUP(SendableClosureCaptures, "sendable-closure-captures")
GROUP(SendableMetatypes, "sendable-metatypes")
GROUP(SendingClosureRisksDataRace, "sending-closure-risks-data-race")

View File

@@ -433,13 +433,13 @@ ERROR(wrong_linkage_for_serialized_function,none,
"function has wrong linkage to be called from %0", (StringRef))
NOTE(performance_called_from,none,
"called from here", ())
ERROR(manualownership_copy,none,
"explicit 'copy' required here; please report this vague diagnostic as a bug", ())
ERROR(manualownership_copy_happened,none,
GROUPED_WARNING(manualownership_copy,SemanticCopies,none,
"implicit 'copy' happens here; please report this vague diagnostic as a bug", ())
GROUPED_WARNING(manualownership_copy_happened,SemanticCopies,none,
"accessing %0 may produce a copy; write 'copy' to acknowledge or 'consume' to elide", (Identifier))
ERROR(manualownership_copy_demanded,none,
GROUPED_WARNING(manualownership_copy_demanded,SemanticCopies,none,
"independent copy of %0 is required here; write 'copy' to acknowledge or 'consume' to elide", (Identifier))
ERROR(manualownership_copy_captured,none,
GROUPED_WARNING(manualownership_copy_captured,SemanticCopies,none,
"closure capture of '%0' requires independent copy of it; write [%0 = copy %0] in the closure's capture list to acknowledge", (StringRef))
// 'transparent' diagnostics

View File

@@ -1,4 +1,5 @@
// RUN: %target-swift-frontend %s -emit-sil -verify \
// RUN: -Werror SemanticCopies \
// RUN: -enable-experimental-feature ManualOwnership
// REQUIRES: swift_feature_ManualOwnership

View File

@@ -0,0 +1,3 @@
# Semantic Copies (Experimental Diagnostics)
TODO explain