Skip to content

Commit 5e6c23e

Browse files
committed
[Sema] diagnostic for conditional Copyable
We were allowing the catch-all "X is not compatible with generics yet" diagnostic to be emitted when there's a failure to satisfy a requirement for a conditional Copyable conformance. Instead, allow the existing infrastructure to diagnose such failures-to-conform to emit a diagnostic . This patch also adds a check to catch future catch-all diagnostics in asserts builds, since I'd like to phase out that diagnostic when NoncopyableGenerics is enabled.
1 parent 1e0c6c2 commit 5e6c23e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6279,7 +6279,7 @@ bool NotCopyableFailure::diagnoseAsError() {
62796279
}
62806280

62816281
case NoncopyableMatchFailure::CopyableConstraint: {
6282-
auto *loc = getLocator();
6282+
ConstraintLocator *loc = getLocator();
62836283
auto path = loc->getPath();
62846284

62856285
if (loc->isLastElement<LocatorPathElt::AnyTupleElement>()) {
@@ -6347,11 +6347,27 @@ bool NotCopyableFailure::diagnoseAsError() {
63476347
if (diagnoseGenericTypeParamType(subject->getAs<GenericTypeParamType>()))
63486348
return true;
63496349
}
6350+
6351+
if (loc->getLastElementAs<LocatorPathElt::ConditionalRequirement>())
6352+
return false; // Allow MissingConformanceFailure to diagnose instead.
6353+
63506354
break;
63516355
}
6352-
}
6356+
} // end switch
63536357

6358+
// emit catch-all diagnostic
63546359
emitDiagnostic(diag::noncopyable_generics, noncopyableTy);
6360+
6361+
#ifndef NDEBUG
6362+
if (getASTContext().LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
6363+
#pragma clang diagnostic push
6364+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
6365+
getLocator()->dump(&getConstraintSystem());
6366+
#pragma clang diagnostic pop
6367+
llvm_unreachable("NoncopyableGenerics: vague diagnostic for locator");
6368+
}
6369+
#endif
6370+
63556371
return true;
63566372
}
63576373

0 commit comments

Comments
 (0)