Skip to content

Commit c3d2618

Browse files
committed
describe noncopyables in parameter packs
1 parent 4863c62 commit c3d2618

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7221,6 +7221,9 @@ ERROR(noncopyable_generics_generic_param_metatype, none,
72217221
NOTE(noncopyable_generics_implicit_copyable, none,
72227222
"%0 %1 has an implicit Copyable requirement",
72237223
(DescriptiveDeclKind, Type))
7224+
ERROR(noncopyable_element_of_pack_not_supported,none,
7225+
"parameter pack containing noncopyable element %0 is not supported",
7226+
(Type))
72247227
ERROR(noncopyable_effectful_getter,none,
72257228
"%0 of noncopyable type cannot be 'async' or 'throws'", (DescriptiveDeclKind))
72267229
ERROR(noncopyable_enums_do_not_support_indirect,none,

lib/Sema/CSDiagnostics.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6118,6 +6118,12 @@ bool NotCopyableFailure::diagnoseAsError() {
61186118
return true;
61196119
}
61206120

6121+
if (loc->isLastElement<LocatorPathElt::PackElement>()) {
6122+
emitDiagnostic(diag::noncopyable_element_of_pack_not_supported,
6123+
noncopyableTy);
6124+
return true;
6125+
}
6126+
61216127
// a bit paranoid of nulls and such...
61226128
if (auto *genericParam = loc->getGenericParameter()) {
61236129
if (auto *paramDecl = genericParam->getDecl()) {

test/Constraints/moveonly_constraints.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,5 @@ func tryToDoBadMetatypeStuff() {
289289

290290
func packingHeat<each T>(_ t: repeat each T) {}
291291
func packIt() {
292-
packingHeat(MO()) // expected-error {{noncopyable type 'MO' cannot be used with generics yet}}
292+
packingHeat(MO()) // expected-error {{parameter pack containing noncopyable element 'MO' is not supported}}
293293
}

0 commit comments

Comments
 (0)