Skip to content

Commit 5111b0b

Browse files
committed
update and strengthen ~Copyable diagnostics
1 parent 46a9061 commit 5111b0b

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6859,8 +6859,8 @@ ERROR(moveonly_cast,none,
68596859
"move-only types cannot be conditionally cast", ())
68606860
ERROR(moveonly_failable_init,none,
68616861
"move-only types cannot have failable initializers yet", ())
6862-
ERROR(moveonly_objc_enum_banned, none,
6863-
"@objc enums cannot be marked as move-only", ())
6862+
ERROR(noncopyable_objc_enum, none,
6863+
"@objc enums cannot be noncopyable", ())
68646864

68656865
//------------------------------------------------------------------------------
68666866
// MARK: Conformance suppression diagnostics
@@ -6937,8 +6937,8 @@ ERROR(concurrency_task_to_thread_model_global_actor_annotation,none,
69376937
"annotating a type with a global actor %0 is not permitted within %1",
69386938
(TypeRepr*, StringRef))
69396939

6940-
ERROR(moveOnly_not_allowed_here,none,
6941-
"'moveOnly' only applies to structs or enums", ())
6940+
ERROR(noncopyable_only_struct_enum,none,
6941+
"only structs or enums can be noncopyable", ())
69426942
ERROR(move_expression_not_passed_lvalue,none,
69436943
"'consume' can only be applied to lvalues", ())
69446944
ERROR(borrow_expression_not_passed_lvalue,none,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ void AttributeChecker::visitMoveOnlyAttr(MoveOnlyAttr *attr) {
21682168
D->getASTContext().LangOpts.hasFeature(Feature::MoveOnlyClasses)))
21692169
return;
21702170

2171-
diagnose(attr->getLocation(), diag::moveOnly_not_allowed_here)
2171+
diagnose(attr->getLocation(), diag::noncopyable_only_struct_enum)
21722172
.fixItRemove(attr->getRange());
21732173
}
21742174

lib/Sema/TypeCheckDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,10 @@ bool IsMoveOnlyRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
960960
return true;
961961
}
962962

963+
// At this point, we have Copyable suppressed on some type decl that isn't
964+
// allowed to have it suppressed, so diagnose!
965+
966+
decl->diagnose(diag::noncopyable_only_struct_enum);
963967
return false;
964968
}
965969

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26662666
//
26672667

26682668
if (ED->isObjC() && ED->isMoveOnly()) {
2669-
ED->diagnose(diag::moveonly_objc_enum_banned);
2669+
ED->diagnose(diag::noncopyable_objc_enum);
26702670
}
26712671
// FIXME(kavon): see if these can be integrated into other parts of Sema
26722672
diagnoseCopyableTypeContainingMoveOnlyType(ED);

0 commit comments

Comments
 (0)