Skip to content

Commit 8072eef

Browse files
committed
describe noncopyables in parameter packs
1 parent 485bdc7 commit 8072eef

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
@@ -7287,6 +7287,9 @@ ERROR(noncopyable_generics_generic_param_metatype, none,
72877287
NOTE(noncopyable_generics_implicit_copyable, none,
72887288
"%0 %1 has an implicit Copyable requirement",
72897289
(DescriptiveDeclKind, Type))
7290+
ERROR(noncopyable_element_of_pack_not_supported,none,
7291+
"parameter pack containing noncopyable element %0 is not supported",
7292+
(Type))
72907293
ERROR(noncopyable_effectful_getter,none,
72917294
"%0 of noncopyable type cannot be 'async' or 'throws'", (DescriptiveDeclKind))
72927295
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
@@ -6163,6 +6163,12 @@ bool NotCopyableFailure::diagnoseAsError() {
61636163
return true;
61646164
}
61656165

6166+
if (loc->isLastElement<LocatorPathElt::PackElement>()) {
6167+
emitDiagnostic(diag::noncopyable_element_of_pack_not_supported,
6168+
noncopyableTy);
6169+
return true;
6170+
}
6171+
61666172
// a bit paranoid of nulls and such...
61676173
if (auto *genericParam = loc->getGenericParameter()) {
61686174
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)