The complete list of Swift 6.4 diagnostic groups for @diagnose, -Werror and -Wwarning. Finding these names shouldn't be this annoying.
September 2026 · Juho KoskelaSwift 6.4’s @diagnose is an excellent little feature. It lets you decide which compiler warnings should become errors, which should stay warnings, and which should shut up for a particular declaration:
@diagnose(VariableNeverMutated, as: error)
func example() {
var count = 1
print(count)
}
Here, Swift’s usual suggestion to change var to let becomes a build failure. The options are error, warning, and ignored, without leading dots. Actual compiler errors, fortunately, cannot be suppressed.
The optional reason: argument takes a string literal, useful for leaving a paper trail when you suppress a warning. For a deprecated oldAPI():
@diagnose(DeprecatedDeclaration, as: ignored, reason: "Keep compatibility until the migration is complete.")
func bridgeToLegacyAPI() { oldAPI() }
Then you need another group name, and the pleasant part ends.
In Xcode 27.0, I don’t get completions for diagnostic group names in @diagnose. swiftc -help-hidden has no obvious flag to list them all either. We’ve got fine-grained control over compiler warnings, provided we already know the magic words.
This feels like a slightly ridiculous problem to have. Anyway, here’s the list.
Generated from Swift 6.4.0’s DiagnosticGroups.def, tag swift-6.4.0-RELEASE, compiler commit b8189d766d86ad7fc8106787d6ce9e402f38dd72. Check DiagnosticGroups.def for newer toolchains.
The same names work with SE-0443’s compiler flags: for example, -Werror DeprecatedDeclaration and -Wwarning VariableNeverMutated.
I type-checked all 75 names in all three @diagnose modes and passed them to both compiler flags using Apple Swift 6.4 (swiftlang-6.4.0.34.1). I treated warnings as errors, so an unknown name would have failed the check.
Names are case-sensitive. The list below is sorted case-insensitively. Some groups contain warnings that are ignored by default, so you won’t necessarily encounter them in a default build.
ActorIsolatedCall
ActorIsolatedMutatingAsync
AddPreconcurrencyImport
AlwaysAvailableDomain
AvailabilityUnrecognizedName
ClangDeclarationImport
CompilationCaching
ConformanceIsolation
ConversionFromIsolatedAnyToSynchronous
DeprecatedDeclaration
DynamicCallable
DynamicExclusivity
EmbeddedRestrictions
ErrorInFutureSwiftVersion
ExclusivityViolation
ExistentialAny
ExistentialMemberAccess
ExistentialType
ExplicitSendable
ForeignReferenceType
ImplementationOnlyDeprecated
ImplicitStrongCapture
InconsistentImportAccess
IsolatedConformances
MemberImportVisibility
MissingModuleOnKnownPaths
ModuleNotTestable
ModuleSelfImport
ModuleVersionMissing
MultipleInheritance
MutableGlobalVariable
NominalTypes
NonisolatedNonsendingByDefault
NonSendableExitingActor
NonSendableInAsyncConformanceOrOverride
NonSendableObjCInterop
NonSendableSuperclass
NoUsage
NoUseUnstructuredThrowingTask
OldSuppressedAssociatedTypes
OpaqueTypeInference
OptionObsoletedByModuleSelectors
OSLog
PackageModuleLoadedFromSDK
PerformanceHints
PreconcurrencyImport
PropertyWrappers
ProtocolTypeNonConformance
RegionIsolation
ResultBuilderMethods
ReturnTypeImplicitCopy
SemanticCopies
SendableClosureCaptures
SendableMetatypes
SendingClosureRisksDataRace
SendingRisksDataRace
SPIImportIgnored
StrictLanguageFeatures
StrictMemorySafety
StringInterpolationConformance
TemporaryPointers
TrailingClosureMatching
UnavailableSendableConformance
UnknownWarningGroup
UnnecessaryEffectMarker
UnnecessaryUnsafe
UnrecognizedStrictLanguageFeatures
UnsupportedScopedImport
UntypedThrows
UnusedImportAccess
UseAnyAppleOSAvailability
UselessAvailabilityCheck
UselessConditionalStatement
VariableNeverMutated
WeakMutability
The compiler also accepts the internal no_group identifier, but I wouldn’t treat it as a supported user-facing diagnostic group.
There’s a warning group for unknown warning groups: UnknownWarningGroup. Misspell a name after -Werror or -Wwarning and you’ll meet it. Typos in @diagnose produce a separate, ungrouped warning in this toolchain. @diagnose(UnknownWarningGroup, as: ignored) won’t silence it. Even the warning about warnings has a caveat.
Swift’s compiler diagnostics catalogue has documentation for many of these groups.
If you’ve already got the warning, ask the compiler to name its group:
swiftc -print-diagnostic-groups Foo.swift
Or, in a Swift package:
swift build -Xswiftc -print-diagnostic-groups
In Xcode, add -print-diagnostic-groups to Other Swift Flags (OTHER_SWIFT_FLAGS) in your target’s build settings.
Look for a suffix such as [#VariableNeverMutated]. Despite its promising name, -print-diagnostic-groups only labels diagnostics emitted by that compilation. It doesn’t print the complete list, and not every diagnostic has a named group. SE-0443 explains the behavior.
This list will eventually be out of date. Let me at least make it reproducible.
The names are the first argument of each GROUP(...) entry in include/swift/AST/DiagnosticGroups.def. This reproduces the list above, omitting no_group and sorting alphabetically without regard to case:
ref=b8189d766d86ad7fc8106787d6ce9e402f38dd72
curl -fsSL "https://raw.githubusercontent.com/swiftlang/swift/$ref/include/swift/AST/DiagnosticGroups.def" |
sed -nE 's/^GROUP\([[:space:]]*([A-Za-z_][A-Za-z_0-9]*)[[:space:]]*,.*/\1/p' |
sed '/^no_group$/d' |
LC_ALL=C sort -f
For another Swift version, change ref to the relevant tag or commit. main shows current development names, which your installed compiler may not recognize. GROUP_LINK(...) entries connect existing groups; they do not introduce new names.
I’d still like a compiler flag that prints the list.