Skip to content

Commit ddd9914

Browse files
Merge pull request #80524 from AnthonyLatsis/diag-descriptive-decl-kind
AST: Cut down on `DescriptiveDeclKind` usage in diagnostics
2 parents 08d46d2 + 5c190b9 commit ddd9914

File tree

64 files changed

+638
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+638
-726
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ enum class DescriptiveDeclKind : uint8_t {
169169
PostfixOperator,
170170
PrecedenceGroup,
171171
TypeAlias,
172+
GenericTypeAlias,
172173
GenericTypeParam,
173174
AssociatedType,
174175
Type,
@@ -183,7 +184,6 @@ enum class DescriptiveDeclKind : uint8_t {
183184
GenericClass,
184185
GenericActor,
185186
GenericDistributedActor,
186-
GenericType,
187187
Subscript,
188188
StaticSubscript,
189189
ClassSubscript,

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ ERROR(conforms_to_ambiguous,none,
282282
"ambiguous reference to protocol '%0' in specified protocol conformance; module '%1' contains multiple protocols named '%0'", (StringRef, StringRef))
283283

284284
ERROR(conforms_to_not_protocol,none,
285-
"%0 %1 referenced in protocol conformance '%2' is not a protocol", (DescriptiveDeclKind, ValueDecl *, StringRef))
285+
"%kind0 referenced in protocol conformance '%1' is not a protocol",
286+
(const ValueDecl *, StringRef))
286287

287288
ERROR(failed_base_method_call_synthesis,none,
288289
"failed to synthesize call to the base method %0 of type %0",

include/swift/AST/DiagnosticsCommon.def

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
ERROR(invalid_diagnostic,none,
2424
"INTERNAL ERROR: this diagnostic should not be produced", ())
2525

26+
NOTE(kind_declname_declared_here,none,
27+
"%0 %1 declared here", (DescriptiveDeclKind, DeclName))
28+
NOTE(decl_declared_here_with_kind,none,
29+
"%kind0 declared here", (const Decl *))
30+
2631
ERROR(not_implemented,none,
2732
"INTERNAL ERROR: feature not implemented: %0", (StringRef))
2833

@@ -176,9 +181,6 @@ ERROR(circular_enum_inheritance,none,
176181
ERROR(circular_protocol_def,none,
177182
"protocol %0 refines itself", (Identifier))
178183

179-
NOTE(kind_declname_declared_here,none,
180-
"%0 %1 declared here", (DescriptiveDeclKind, DeclName))
181-
182184
WARNING(warn_property_wrapper_module_scope,none,
183185
"ignoring associated type %0 in favor of module-scoped property "
184186
"wrapper %0; please qualify the reference with %1",

include/swift/AST/DiagnosticsCommon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include "swift/Config.h"
2525

2626
namespace swift {
27+
class AccessorDecl;
2728
class ConstructorDecl;
29+
class MacroDecl;
30+
class SubscriptDecl;
2831
class SwitchStmt;
2932
class TypeAliasDecl;
3033

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ ERROR(disallowed_var_multiple_getset,none,
229229
"'var' declarations with multiple variables cannot have explicit"
230230
" getters/setters", ())
231231
ERROR(stub_decl_cannot_have_body,none,
232-
"stub %0 cannot have body",
233-
(DescriptiveDeclKind))
232+
"stub %kindonly0 cannot have body",
233+
(const Decl *))
234234

235235
ERROR(disallowed_init,none,
236236
"initial value is not allowed here", ())

include/swift/AST/DiagnosticsSIL.def

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ ERROR(missing_never_call_closure,none,
315315
(Type))
316316

317317
ERROR(missing_return_decl,none,
318-
"missing return in %1 expected to return %0",
319-
(Type, DescriptiveDeclKind))
318+
"missing return in %kindonly1 expected to return %0",
319+
(Type, const AbstractFunctionDecl *))
320320
ERROR(missing_never_call_decl,none,
321-
"%1 with uninhabited return type %0 is missing "
321+
"%kindonly1 with uninhabited return type %0 is missing "
322322
"call to another never-returning function on all paths",
323-
(Type, DescriptiveDeclKind))
323+
(Type, const AbstractFunctionDecl *))
324324

325325
NOTE(missing_return_last_expr_note,none,
326326
"did you mean to return the last expression?", ())
@@ -701,8 +701,9 @@ WARNING(warning_int_to_fp_inexact, none,
701701

702702
// Flow-isolation diagnostics
703703
ERROR(isolated_after_nonisolated, none,
704-
"cannot access %1 %2 here in %select{nonisolated initializer|deinitializer}0",
705-
(bool, DescriptiveDeclKind, DeclName))
704+
"cannot access %kind1 here in "
705+
"%select{nonisolated initializer|deinitializer}0",
706+
(bool, const ValueDecl *))
706707
NOTE(nonisolated_blame, none, "after %1%2 %3, "
707708
"only nonisolated properties of 'self' can be accessed from "
708709
"%select{this init|a deinit}0", (bool, StringRef, StringRef, DeclName))
@@ -981,16 +982,16 @@ NOTE(regionbasedisolation_type_use_after_send, none,
981982
"sending value of non-Sendable type %0 to %1 callee risks causing data races between %1 and local %2 uses",
982983
(Type, ActorIsolation, ActorIsolation))
983984
NOTE(regionbasedisolation_type_use_after_send_callee, none,
984-
"sending value of non-Sendable type %0 to %1 %2 %3 risks causing data "
985-
"races between %1 and local %4 uses",
986-
(Type, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
985+
"sending value of non-Sendable type %0 to %1 %kind2 risks causing data "
986+
"races between %1 and local %3 uses",
987+
(Type, ActorIsolation, const ValueDecl *, ActorIsolation))
987988

988989
NOTE(regionbasedisolation_named_info_send_yields_race, none,
989990
"sending %1%0 to %2 callee risks causing data races between %2 and local %3 uses",
990991
(Identifier, StringRef, ActorIsolation, ActorIsolation))
991992
NOTE(regionbasedisolation_named_info_send_yields_race_callee, none,
992-
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and local %5 uses",
993-
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
993+
"sending %1%0 to %2 %kind3 risks causing data races between %2 and local %4 uses",
994+
(Identifier, StringRef, ActorIsolation, const ValueDecl *, ActorIsolation))
994995

995996
// Use after send closure.
996997
NOTE(regionbasedisolation_type_isolated_capture_yields_race, none,
@@ -1013,8 +1014,8 @@ NOTE(regionbasedisolation_typed_use_after_sending, none,
10131014
"Passing value of non-Sendable type %0 as a 'sending' argument risks causing races in between local and caller code",
10141015
(Type))
10151016
NOTE(regionbasedisolation_typed_use_after_sending_callee, none,
1016-
"Passing value of non-Sendable type %0 as a 'sending' argument to %1 %2 risks causing races in between local and caller code",
1017-
(Type, DescriptiveDeclKind, DeclName))
1017+
"Passing value of non-Sendable type %0 as a 'sending' argument to %kind1 risks causing races in between local and caller code",
1018+
(Type, const ValueDecl *))
10181019

10191020
//===
10201021
// Sending Never Sendable Emitter
@@ -1023,8 +1024,8 @@ NOTE(regionbasedisolation_named_send_never_sendable, none,
10231024
"sending %1%0 to %2 callee risks causing data races between %2 and %3 uses",
10241025
(Identifier, StringRef, ActorIsolation, StringRef))
10251026
NOTE(regionbasedisolation_named_send_never_sendable_callee, none,
1026-
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and %5 uses",
1027-
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, StringRef))
1027+
"sending %1%0 to %2 %kind3 risks causing data races between %2 and %4 uses",
1028+
(Identifier, StringRef, ActorIsolation, const ValueDecl *, StringRef))
10281029

10291030
NOTE(regionbasedisolation_named_send_into_sending_param, none,
10301031
"%0%1 is passed as a 'sending' parameter; Uses in callee may race with "
@@ -1048,8 +1049,8 @@ NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_
10481049
"closure captures %0 which is accessible to code in the current task",
10491050
(DeclName))
10501051
NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_boxed_value_task_isolated, none,
1051-
"closure captures reference to mutable %1 %0 which is accessible to code in the current task",
1052-
(DeclName, DescriptiveDeclKind))
1052+
"closure captures reference to mutable %kind0 which is accessible to code in the current task",
1053+
(const ValueDecl *))
10531054
NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_region, none,
10541055
"closure captures %1 which is accessible to %0 code",
10551056
(StringRef, DeclName))
@@ -1065,8 +1066,8 @@ NOTE(regionbasedisolation_closure_captures_actor, none,
10651066
(DeclName, StringRef))
10661067

10671068
NOTE(regionbasedisolation_typed_tns_passed_to_sending_callee, none,
1068-
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter to %2 %3 risks causing races inbetween %0 uses and uses reachable from %3",
1069-
(StringRef, Type, DescriptiveDeclKind, DeclName))
1069+
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter to %kind2 risks causing races inbetween %0 uses and uses reachable from %2",
1070+
(StringRef, Type, const ValueDecl *))
10701071

10711072
NOTE(regionbasedisolation_named_send_nt_asynclet_capture, none,
10721073
"sending %1 %0 into async let risks causing data races between nonisolated and %1 uses",
@@ -1075,8 +1076,8 @@ NOTE(regionbasedisolation_typed_sendneversendable_via_arg, none,
10751076
"sending %0 value of non-Sendable type %1 to %2 callee risks causing races in between %0 and %2 uses",
10761077
(StringRef, Type, ActorIsolation))
10771078
NOTE(regionbasedisolation_typed_sendneversendable_via_arg_callee, none,
1078-
"sending %0 value of non-Sendable type %1 to %2 %3 %4 risks causing races in between %0 and %2 uses",
1079-
(StringRef, Type, ActorIsolation, DescriptiveDeclKind, DeclName))
1079+
"sending %0 value of non-Sendable type %1 to %2 %kind3 risks causing races in between %0 and %2 uses",
1080+
(StringRef, Type, ActorIsolation, const ValueDecl *))
10801081

10811082
// Error that is only used when the send non sendable emitter cannot discover any
10821083
// information to give a better diagnostic.

0 commit comments

Comments
 (0)