Commit Graph

84 Commits

Author SHA1 Message Date
Allan Shortlidge
7436be514a Merge pull request #82083 from tshortli/diagnose-unrecognized-availability-domains-as-errors-6.2
[6.2] AST: Diagnose unrecognized platforms as errors with `CustomAvailability` enabled
2025-06-09 18:16:02 -07:00
Allan Shortlidge
f5bae411ca AST: Diagnose unrecognized platforms as errors with CustomAvailability enabled.
When the CustomAvailability experimental feature is enabled, make it an error
to specify an unrecognized availability domain name. Also, add these
diagnostics to a diagnostic group so that developers can control their behavior
when they are warnings.

Resolves rdar://152741624.
2025-06-06 22:44:12 -07:00
Allan Shortlidge
464c37a5bb AST: Add a warning group for @_implementationOnly deprecation diagnostics.
This allows developers to control the level of these diagnostics.

Resolves rdar://152735425.
2025-06-06 19:41:42 -07:00
Artem Chikin
e37071bcd4 Add a new diagnostic group and documentation for the module-not-found failure which specifies that a missing module dependency can be found on a search path serialized in another Swift binary module dependency. 2025-06-05 10:24:56 -07:00
Doug Gregor
c1358c5b22 Add a diagnostic group for the diagnostic about non-Sendable metatypes.
This is a new restriction that folks are sure to run into, so provide
it with some actionable documentation. Fixes rdar://152450956.

(cherry picked from commit 9f0dda5417)
2025-06-04 09:48:38 -07:00
Allan Shortlidge
c99b19e450 AST/Sema: Make MemberImportVisibility a migratable feature.
The migration to `MemberImportVisibility` can be performed mechanically by
adding missing import declarations, so offer automatic migration for the
feature.

Resolves rdar://151931597.
2025-06-02 07:27:41 -07:00
Michael Gottesman
0d519a1acb [sema] Change non-sendable -> non-Sendable in diagnostics.
This matches send non sendable but importantly also makes it clear that we are
talking about something that doesn't conform to the Sendable protocol which is
capitalized.

rdar://151802975
(cherry picked from commit 3ed4059a60)
2025-05-23 10:31:05 -07:00
Pavel Yaskevich
6c54fe142a [Diagnostics] Replace last references to AsyncCallerExecution with NonisolatedNonsendingByDefault
(cherry picked from commit 0bcbde4940)
2025-05-12 13:37:58 -07:00
Pavel Yaskevich
1b79cdc4c3 [Diagnostics] Rename the note file to match the NonisolatedNonsendingByDefault feature group declaration
(cherry picked from commit fbaf7ce017)
2025-05-12 13:36:41 -07:00
Allan Shortlidge
e867788d65 ClangImporter: Introduce the #ClangDeclarationImport diagnostic group.
The warnings that ClangImporter emits about issues it encounters while
importing declarations from Clang modules should all belong to a diagnostic
group so that users of `-warnings-as-errors` can control their behavior using
the compiler flags introduce with SE-0443. It's especially important that these
diagnostics be controllable since they are often caused by external
dependencies and therefore the developer may not have any control over whether
they are emitted.

The `#ClangDeclarationImport` diagnostic group is intentionally broad so that
developers have a way to control all of these diagnostics with a single
`-Wwarning` flag. I fully expect that we'll introduce finer-grained diagnostic
groups for some of these diagnostics in the future, but those groups should be
hierarchically nested under `#ClangDeclarationImport`, which is supported by
SE-0443.

Resolves rdar://150524204.
2025-05-05 14:19:04 -07:00
Pavel Yaskevich
c8c7eef43e [Docs] NFC: Remove last remaining references to @execution attribute
(cherry picked from commit 4b1695b999)
2025-04-16 13:20:16 -07:00
Pavel Yaskevich
dafc31ae08 [Diagnostics] Update educational note for AsyncCallerExecution feature to match @execution attribute split 2025-04-16 13:20:16 -07:00
Doug Gregor
1c5372858b [SE-0470] Ensure that one cannot form an isolated conformance when Self: Sendable
While here, fix some issues around implied isolated conformances (we
could get into an inconsistent state). Also provide an educational
note discussing isolated conformances and the kinds of errors one can
see when they are used from outside of their isolation domain.
2025-04-02 18:19:09 -07:00
Doug Gregor
da34300a44 Improve diagnostic group documentation for strict memory safety
This both had the wrong file name (so it couldn't be found), and was a
bit out-of-date. Update it.
2025-03-28 15:05:18 -07:00
Doug Gregor
8fd02d7ccd Merge pull request #80190 from DougGregor/conformance-isolation-diagnostics
Rework diagnostics for conformance isolation failures
2025-03-21 02:54:53 -07:00
Doug Gregor
1b1f28decb Tighten up diagnostics wording a bit 2025-03-20 22:13:19 -07:00
Doug Gregor
9ea735b9ed Rework diagnostics for conformance isolation failures
A protocol conformance can be ill-formed due to isolation mismatches
between witnesses and requirements, or with associated conformances.
Previously, such failures would be emitted as a number of separate
errors (downgraded to warnings in Swift 5), one for each witness and
potentially an extra for associated conformances. The rest was a
potential flood of diagnostics that was hard to sort through.

Collect all of the isolation-related problems for a given conformance
together and produce a single error (downgraded to a warning when
appropriate) that describes the overall issue. That error will have up
to three notes suggesting specific courses of action:
* Isolating the conformance (when the experimental feature is enabled)
* Marking the witnesses as 'nonisolated' where needed
*

The diagnostic also has notes to point out the witnesses/associated
conformances that have isolation problems. There is a new educational
note that also describes these options.

We give the same treatment to missing 'distributed' on witnesses to a
distributed protocol.
2025-03-20 21:23:16 -07:00
Anthony Latsis
c49947579a Sema: Implement adoption mode for AsyncCallerExecution 2025-03-18 01:58:31 +00:00
Holly Borla
3a744d2116 Merge pull request #79509 from hborla/educational-notes
[Educational Notes] Start adding educational notes for data-race safety.
2025-03-04 11:22:11 -08:00
Holly Borla
fdd7402bbf [Educational Notes] Add an explanation for sending closure arguments. 2025-03-03 21:44:30 -08:00
Holly Borla
0f7c991eec [Educational Notes] Add an explanation for actor-isolated calls from
synchronous nonisolated contexts.
2025-03-03 21:44:30 -08:00
Holly Borla
cf437719fa [Educational Notes] Add an explanation for captures in a @Sendable
closure.
2025-03-03 21:40:59 -08:00
Holly Borla
4353c5a2fe [Educational Notes] Add an explanation for the unsafe global variable
errors.
2025-03-03 21:22:33 -08:00
Holly Borla
72eab9f02a [Educational Notes] Add an explanation for `sending 'x' risks causing
data races`.
2025-03-03 21:22:33 -08:00
Doug Gregor
f45271f569 Move diagnostic group documentation in with educational notes
Since these different forms of documentation have a similar purpose,
and there's already some infrastructure for educational notes, unify all of
the diagnostics-related documentation in a single place.

We might consider unifying these ideas in the compiler as well, but
that's for another day.
2025-02-27 21:19:02 -08:00
Doug Gregor
05447cec16 Rename diagnostic group Markdown files
Match the kebab-case form used by educational notes.
2025-02-27 16:08:47 -08:00
Doug Gregor
7977e4682c Add a ChangeLog entry for SE-0458 2025-02-26 13:13:05 -08:00
Holly Borla
f1492fe553 [Educational Notes] Remove complex-closure-inference.
This educational note was obsoleted by SE-0362.
2025-02-19 21:19:06 -08:00
Anthony Latsis
3222053810 AST: Add a diagnostic group for any syntax diagnostics
Allow users to escalate `any` syntax warnings to errors with
`-Werror ExistentialAny`.
2025-02-12 22:22:10 +00:00
Allan Shortlidge
24f5632ca1 Frontend: Implement optional parsing diagnostics for enabled language features.
Parsing for `-enable-upcoming-feature` and `-enable-experimental-feature` is
lenient by default because some projects need to be compatible with multiple
language versions and compiler toolchains simultaneously, and strict
diagnostics would be a nuisance. On the other hand, though, it would be useful
to get feedback from the compiler when you attempt to enable a feature that
doesn't exist. This change splits the difference by introducing new diagnostics
for potential feature enablement misconfigurations but leaves those diagnostics
ignored by default. Projects that wish to use them can specify `-Wwarning
StrictLanguageFeatures`.
2025-01-15 16:34:32 -08:00
Doug Gregor
63c9882852 Introduce the notion of a warning that is ignored by default, but enabled by -Wwarning/-Werror
As an example, use this for the "`@preconcurrency` on import has no
effect" warning, which is not yet working correctly. This disables it
by default but leaves it in place for our testing.
2025-01-10 09:10:56 -08:00
Anthony Latsis
9ae3cf1034 AST: Delete the DeclarationUnavailableFromAsynchronousContext diagnostic group
This group has not shipped yet and was added mainly to support test
coverage for d56b7df8a9. Now that we have
unit tests for this, delete the group, pending discussion.
2025-01-07 20:29:07 +00:00
Dmitrii Galimzianov
d56b7df8a9 Add DiagGroupID to Diagnostic
This change addresses the following issue: when an error is being wrapped in a warning, the diagnostic message will use the wrapper's `DiagGroupID` as the warning's name. However, we want to retain the original error's group for use. For example, in Swift 5, async_unavailable_decl is wrapped in error_in_future_swift_version. When we print a diagnostic of this kind, we want to keep the `DiagGroupID` of `async_unavailable_decl`, not that of `error_in_future_swift_version`.
To achieve this, we add `DiagGroupID` to the `Diagnostic` class. When an active diagnostic is wrapped in DiagnosticEngine, we retain the original `DiagGroupID`.

For illustration purposes, this change also introduces a new group: `DeclarationUnavailableFromAsynchronousContext`.

With this change, we produce errors and warnings of this kind with messages like the following:

```
global function 'fNoAsync' is unavailable from asynchronous contexts [DeclarationUnavailableFromAsynchronousContext]
global function 'fNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode [DeclarationUnavailableFromAsynchronousContext]
```
2024-12-03 20:12:11 +01:00
Doug Gregor
7ffa5c324d Put warnings about unsafe constructs into a new diagnostic group Unsafe 2024-11-11 17:50:21 -08:00
Dmitrii Galimzianov
aa5e10f8d2 [Diagnostics] DeprecatedDeclaration group 2024-09-25 23:18:25 +02:00
Dmitrii Galimzianov
9e64b873c3 [Diagnostics] Fix typos and flag names 2024-09-10 21:11:36 +02:00
Dmitrii Galimzianov
28883b6654 [Diagnostics] Add -[no-]warning-as-error flags for precise control over warning behavior
This commit adds new compiler options -no-warning-as-error/-warning-as-error which allows users to specify behavior for exact warnings and warning groups.
2024-09-07 01:14:43 +02:00
Holly Borla
466a021caa [Diagnostics] Add an educational note for error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Anthony Latsis
ccaa6707fe Docs: Reattach, rewrite and rename the «associated-type-requirements» educational note 2021-08-30 22:27:13 +03:00
Kavon Farvardin
c0607b345f Revert "Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic"
The following regression test added for this feature is not passing:

Swift(linux-x86_64) :: decl/protocol/protocols_with_self_or_assoc_reqs_executable.swift

with a compiler crash happening during SILFunctionTransform "Devirtualizer".

Reverting to unblock CI.

This reverts commit f96057e260, reversing
changes made to 3fc18f3603.
2021-08-26 16:46:42 -07:00
Anthony Latsis
fbae8a4fdb Docs: Reattach, rewrite and rename the «associated-type-requirements» educational note 2021-08-16 18:30:23 +03:00
Jevon Mao
9397ee59d5 [Diagnostics] Add educational notes explaining multiple inheritance (#38253)
* Add educational notes for multiple inheritance

* Update edu note by adopting reviewer suggestions

* Update userdocs/diagnostics/multiple-class-inheritance.md

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>

* Added Flyable protocol definition to example

* Apply suggestions from code review

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Use consistent terminology

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Use utensils example as suggested by review

* Update title to Multiple Inheritance

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Rename file to match changed name

* Add more objects in protocol construction example

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2021-08-01 08:06:38 -04:00
jiaren wang
c5de1f0800 [SR-14824] Improve diagnostic for multi-statement closures instead of saying "too complex closure return type" 2021-06-30 14:36:38 +08:00
Xiaodi Wu
ae35835008 [Docs] Edits for educational note on PATs (#33736)
* [Docs] Minor edits for educational note on PATs

* Adopt reviewer feedback on wording

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>

* Revert a capitalization change

* [Docs] Further revisions based on reviewer feedback for educational note on PATs

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>
2021-03-19 23:46:33 -04:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Doug Gregor
6a40a3a8aa [SE-0289] Add support for @resultBuilder.
"Function builders" are being renamed to "result builders". Add the
corresponding `@resultBuilder` attribute, with `@_functionBuilder` as
an alias for it, Update test cases to use @resultBuilder.
2020-10-20 13:24:51 -07:00
Doug Gregor
25cd671ed5 [Code completion] Test and fix 'static func' for function builder methods. 2020-09-16 15:12:12 -07:00
Doug Gregor
591c8cddec [Function builders] Add an educational note on the build* functions.
Introduce an educational note with a synopsis of the build* function
declarations one can add to a function builder, and associate it with
the diagnostics indicating incorrect or missing build* functions.
2020-09-16 14:01:28 -07:00