Commit Graph

160 Commits

Author SHA1 Message Date
Sam Pyankov 1def6c09dc Merge pull request #89648 from sepy97/diagnostic-group-ipi
[Sema] Group the IPI public-import diagnostic and emit it as a warning
2026-06-09 17:02:59 -07:00
Allan Shortlidge f0745b2143 AST: Introduce the UnnecessaryUnsafe diagnostic group.
Put diagnostics about unnecessary 'unsafe' markers to a dedicated group.

Resolves rdar://177377552.
2026-06-05 15:10:44 -07:00
Allan Shortlidge 4d52c36aa4 AST: Warn when module specified by versioned canImport cannot be found.
If the module named in `#if canImport(<Module>, _version: ...)` cannot be
found, it may indicate that the developer misspelled the module name. Emit a
warning to indicate that the directive evaluates to false. If it is intentional
that the module not be found, the developer can avoid the warning by first
checking whether the module can be imported and then check its version.

Resolves rdar://128367758.
2026-06-05 06:42:18 -07:00
Sam Pyankov 4742af0081 [Sema] Group the IPI public-import diagnostic and emit it as a warning
The initial IPI implementation emits an error when an api/spi-level
module publicly imports an ipi-level module. That is too aggressive for
incremental adoption.

Wrap the diagnostic in a new diagnostic group (IPIVerification) and emit
it as a warning.

Also reword the message from "...from non-internal module 'X'" to a clearer
"...because 'X' has '-library-level api/spi'"

rdar://178560797
2026-06-04 15:16:43 -07:00
Michael Gottesman 399bb5d9a1 [rbi] Replace "task-isolated" with "code in the current isolation context" in diagnostics
"Task-isolated" is an internal implementation term that is not meaningful
to users. Replace it with the user-facing "code in the current isolation context"
formulation throughout region-based isolation diagnostics.

Diagnostic definitions in DiagnosticsSIL.def are updated to accept an
additional bool parameter for task-isolation and use %select to choose
between the actor-isolation string and "code in the current isolation context".
Emission sites in SendNonSendable.cpp are updated to pass
isTaskIsolated() at each call site. All affected test expectations are
updated to match the new output.

rdar://178534037
2026-06-02 09:29:58 -07:00
Allan Shortlidge 8a0f76861d AST: Add the UselessConditionalStatement warning group.
Allow developers to control the behavior of warnings like this:

```
let x = 0
if case _ = x { // warning: 'if' condition is always true
  // ...
}
```

Resolves rdar://178154296.
2026-05-28 16:45:53 -07:00
Allan Shortlidge 5b59053885 Sema: Add diagnostic group for @isolated(any) to synchronous conversion.
Follow-up to https://github.com/swiftlang/swift/pull/80812.

Resolves rdar://153094492.
2026-05-22 14:39:52 -07:00
Allan Shortlidge 6d7706273d Sema: Add diagnostic group for useless availability check warning.
Resolves rdar://177679716.
2026-05-21 21:14:48 -07:00
Guillaume Lessard 464cb164dc Document UnnecessaryEffectMarker warning group. 2026-05-15 02:52:34 -07:00
Michael Gottesman 7f93e1b440 Merge pull request #88662 from gottesmm/pr-af62376cd868f93226ec5353dbf9a0cbd2611b7a
[rbi] Add diagnostic groups and documentation for cross-isolation data race and unknown pattern errors
2026-04-28 16:34:11 -07:00
Michael Gottesman 43bf55cb19 [rbi] Add diagnostic groups and documentation for cross-isolation data race and unknown pattern errors
Introduce two new diagnostic groups: RegionIsolationCrossIsolationDataRace
and RegionIsolationUnknownPattern, both linked as children of the existing
RegionIsolation group. This converts the merge-region-failure errors and the
unknown-pattern error from plain ERROR to GROUPED_ERROR, which allows users
to selectively downgrade these diagnostics (e.g. the unknown pattern error
can be downgraded since it represents a compiler limitation rather than a
definite user error).

Add user-facing documentation for both groups explaining what triggers the
diagnostics and how to resolve them.

rdar://175771878
2026-04-28 10:34:22 -07:00
Allan Shortlidge c0b5e6c7b8 AST: Add a NoUsage diagnostic group.
Adds every diagnostic in the legacy `no-usage` diagnostic category to a new
diagnostic group called NoUsage so that the diagnostics can participate in
diagnostic control mechanisms like `-Werror`.

Resolves rdar://160488389.
2026-04-24 16:56:48 -07:00
Allan Shortlidge e917a21777 AST: Add the AddPreconcurrencyImport diagnostic group. 2026-04-23 15:29:47 -07:00
Allan Shortlidge de35fbd4ff AST: Add the UnsupportedScopedImport diagnostic group. 2026-04-23 15:28:09 -07:00
Allan Shortlidge 04f1bab204 AST: Add the SPIImportIgnored diagnostic group. 2026-04-23 13:20:21 -07:00
Allan Shortlidge 440120557e AST: Introduce the ModuleSelfImport diagnostic group. 2026-04-23 13:06:36 -07:00
Allan Shortlidge 622a68601b AST: Add the InconsistentImportAccess diagnostic group. 2026-04-23 13:06:19 -07:00
Allan Shortlidge f9cbe0293c AST: Add the UnusedImportAccess diagnostic group.
Resolves rdar://147656067.
2026-04-23 13:05:57 -07:00
Pavel Yaskevich f725f50d93 Merge pull request #87439 from ktoso/wip-task-discarding
[Concurrency] Warn about un-used throwing unstructured tasks
2026-04-22 10:52:41 -07:00
Aviva f2c5bbc0af Merge pull request #88194 from a-viv-a/unavailable-conformance
[Sema] Diagnose retroactive conformance for unavailable conformance
2026-04-21 15:36:41 -07:00
Konrad Malawski bfe8dbca59 [Concurrency] Warn about un-used throwing unstructured tasks
Pending swift evolution discussion: https://github.com/swiftlang/swift-evolution/pull/3133

replaces #87171

update new error message according to proposal

also handle untyped throws in _nonDiscardableWhenThrowing attr

Rename the internal attr _nonDiscardableWhenThrowingOperation
2026-04-21 23:53:56 +09:00
Allan Shortlidge 902f13a132 AST: Add group IDs to diags for module interface option obsoletion..
Makes it possible for users of `-warnings-as-errors` to control the behavior of
warnings about the obsoletion of module interface emission options.

Resolves rdar://174787052.
2026-04-15 13:08:31 -07:00
Aviva Ruben 404d1f4b2f [Sema] Diagnose retroactive conformance for unavailable conformance
This commit fixes rdar://166895453 by recognizing unavailable
conformances even for `@unchecked @retroactive` extensions. It also adds
a userdoc to explain unavailable conformances.
2026-04-08 11:41:27 -07:00
Kavon Farvardin 0cfef22ec5 Merge pull request #88329 from kavon/supp-assoc-types-polish
SuppAssocTypesWithDefaults: extra tests + migration guide
2026-04-08 09:22:47 -07:00
Kavon Farvardin e9acbe61ca Docs: fix diagnostic-groups.md 2026-04-06 16:46:34 -07:00
Aviva Ruben 9b9079f75a [Userdocs] Link to swift book on inout, highlight inout exclusivity 2026-04-06 14:21:58 -07:00
Kavon Farvardin 135eb8b0cd Docs: fix URL for SE-503 2026-04-06 13:50:43 -07:00
Kavon Farvardin 67b099aeb8 Diags: add userdocs for feature deprecation warning
There are in fact ABI changes for all suppressed associatedtypes.
Only source changes are expected for suppressed primary associatedtypes.
2026-04-06 13:37:29 -07:00
Aviva aa649de3ca Merge pull request #87939 from a-viv-a/suggest-immutable-witness
Suggest immutable witness
2026-03-30 10:04:33 -07:00
Aviva Ruben 69b6c8cc9e [Sema] Suggest let, nonisolated for properties and computed properties
Fixes rdar://89864078, by checking if all the required vars are
immutable, and suggesting mutable variables be converted to immutable to
become nonisolated and presumably fix the isolation issue. Also suggests
'nonisolated' on var decls without storage or wrapper. Additionally,
converts existing 'nonisolated' for method suggestion to emit per-method
instead of a top level 'all', for consistency with the new diagnostic,
based on PR feedback.
2026-03-23 15:42:18 -07:00
Allan Shortlidge 4276eaac10 userdocs: Re-run ./utils/generate-doc-index.swift. 2026-03-21 05:25:52 -07:00
Allan Shortlidge 1f26971a88 Sema: Introduce an opt-in UseAnyAppleOSAvailability diagnostic group.
Enabling `UseAnyAppleOSAvailability` diagnostics will cause the compiler to
diagnose declarations where `anyAppleOS` availability can be used a concise
replacement for platform-specific availability annotations.

Resolves rdar://163819878.
2026-03-20 16:01:55 -07:00
Artem Chikin 216a4f232e Add diagnostic warning group documentation for the 'ReturnTypeImplicitCopy' group 2026-03-20 09:23:07 +00:00
Artem Chikin b954e4ac73 Add diagnostic warning group documentation for the 'PerformanceHints' group 2026-03-19 16:24:33 +00:00
Aviral Goel d06e05fc6d Add diagnostic warning group documentation for the 'ExistentialType' performance hints sub-group 2026-03-19 11:33:32 +00:00
Aviva 157709a41c Merge pull request #87755 from a-viv-a/clarify-mutating-async-actor-iso-diag
Add diagnostic group and note to explain mutating async function issues
2026-03-18 11:10:18 -07:00
Aviva Ruben 96a58d748a Add diagnostic group, note to explain mutating async function issues
Fixes rdar://145127274 by adding a note that hints at why this cannot be
accepted, and a diagnostic group that spells out the correctness problem
created by the implicit inout self from mutating async methods.
2026-03-17 12:48:42 -07:00
Doug Gregor 0e9bb10bf5 Merge pull request #87833 from DougGregor/untyped-throws-performance-hint
Introduce performance hints for untyped throws
2026-03-13 20:37:34 -07:00
Artem Chikin c0dee449c2 Merge pull request #87749 from artemcm/LocalDiagsForDiagGroup
[Diagnostics] Support diagnostic groups with toolchain-local-only documentation
2026-03-13 14:19:12 +00:00
Doug Gregor c72eab6be5 Introduce performance hints for untyped throws
Untyped throws requires a heap allocation and reference counting for
thrown errors, which can be unacceptable in very
performancce-constrained environments. Introduce a new subgroup of
performance hints, UntypedThrows, to report uses of untyped throws.

This resurrects the code we were using for diagnosing untyped throws
in Embedded Swift, repurposing it as a performance hint, which is more
appropriate.
2026-03-12 13:07:00 -07:00
Doug Gregor 38c6ffbf0d [Embedded] Stop diagnosing untyped throws in embedded mode
It is plausible that we will introduce support for untyped throws in
Embedded Swift at some point, so don't diagnose its presence so
eagerly now. Instead, leave it until later in the pipeline when it's
actually used.

Fixes rdar://162071067, where we were getting entirely too many
warnings about this.
2026-03-11 10:52:20 -07:00
Artem Chikin 2a6ab76bb3 Add option to have a diagnostic group have toolchain-local-only documentation 2026-03-10 15:11:33 +00:00
Doug Gregor 8f469198f1 Regenerate diagnostic groups index 2026-03-09 14:33:06 -07:00
Doug Gregor 454237a083 Allow the OSLog module to specify the log string section name
When building the `OSLog` module, look for a variable named
`osLogStringSectionName`. It must have a string literal as its
initializer, which provides the section name where the log strings
should be emitted. The `OSLog` module should contain something like
this:

    let osLogStringSectionName = "__TEXT,__logit"

When not present, the compiler will default to
`__TEXT,__oslogstring,cstring_literals`, which was previously the
hardcoded section name. Now, OSLog can customize the name.

Implements rdar://171571056
2026-03-09 10:27:54 -07:00
Jamie a2d1591810 [docs]: add docs for ImplicitStrongCapture diagnostic 2026-02-18 05:30:15 -06:00
Ben Barham b29a0a9b3d Fix up the userdocs index
A few docs weren't added to the index, re-run the generation and fix the
test to actually run in order to catch future issues.
2025-12-06 10:18:19 +10:00
Pavel Yaskevich 22ec081377 [AST/Sema] Add a diagnostic group ExplicitSendable to replace -require-explicit-sendable
Always run explicit `Sendable` checks on public types and suppress
warning printing by default instead of using a special compiler argument.

Resolves: rdar://162394810
2025-11-04 17:53:20 -08:00
Kavon Farvardin 6b858b411c ManualOwnership: introduce 'DynamicExclusivity'
We can add warnings about dynamic exclusivity
checks that may happen on an access, with
explainers about why they happen for safety.
2025-10-24 16:59:44 -07:00
Kavon Farvardin 95a6719117 ManualOwnership: introduce 'SemanticCopies' diagnostic group
This includes documentation to explain how to understand
these diagnostics.
2025-10-24 16:59:41 -07:00
John Hui 781489f067 Merge pull request #85021 from j-hui/return-frt-diagnostics
[cxx-interop] Put RETURNS_RETAINED warnings in a diagnostic group

rdar://161932849
rdar://144976203
2025-10-24 12:05:48 -04:00