Commit Graph

20 Commits

Author SHA1 Message Date
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Michael Gottesman
3ed4059a60 [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
2025-05-22 11:37:58 -07:00
Michael Gottesman
082b824a8e [rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL.
The reason why I am doing this is that in certain cases the AST captures indices
will never actually line up with partial apply capture indices since we seem to
"smush" together closures and locally defined functions.

NOTE: The reason for the really small amount of test changes is that this change
does not change the actual output by design. The only cases I had to change were
a case where we began to emit a better diagnostic and also where I added code
coverage around _ and let _ since those require ignored_use to be implemented so
that they would be diagnosed (previously we just did not emit anything so we
couldn't emit the diagnostic at the SIL level).

rdar://142661388
2025-01-22 21:12:36 -08:00
Michael Gottesman
49eee05647 [region-isolation] Treat as Sendable values that are meant to be ignored since they are marked with preconcurrency
rdar://133531625
2024-08-24 13:14:39 -04:00
Michael Gottesman
4bb2e4f3b1 [region-isolation] Improve the error we emit for closure literals captured as a sending parameter.
Specifically:

I changed the main error message to focus on the closure and that the closure
is being accessed concurrently.

If we find that we captured a value that is the actual isolation source, we
emit that the capture is actually actor isolated.

If the captured value is in the same region as the isolated value but is not
isolated, we instead say that the value is accessible from *-isolated code or
code within the current task.

If we find multiple captures and we do not which is the actual value that was
in the same region before we formed the partial apply, we just emit a note on
the captures saying that the closure captures the value.

I changed the diagnostics from using the phrase "task-isolated" to use some
variant of accessible to code in the current task.

The idea is that in all situations we provide a breadcrumb that the user can
start investigating rather than just saying that the closure is "task-isolated".

From a preconcurrency perspective, I made it so that we apply the preconcurrency
behavior of all of the captures. This means that if one of the captures is
preconcurrency, we apply the preconcurrency restriction to the closure. This is
one step towards making it so that preconcurrency applies at the region level...
we just are not completely there yet.

rdar://133798044
2024-08-14 10:37:31 -07:00
Michael Gottesman
e7e035f60c [region-isolation] Convert the transfer non sendable typed error to be a new short-error, long-note form error.
I also messed with the text a little bit.

This eliminates the last of the old style diagnostics.
2024-07-31 13:10:02 -07:00
Michael Gottesman
4697546e09 [sending] Mark Task.init,detached, and friends as sending methods instead of __owned @Sendable so we can capture non-isolated values. 2024-06-21 02:24:03 -07:00
Michael Gottesman
99e3f7fb13 [region-isolation] Make RegionBasedIsolation an upcoming feature for swift 6.
To make the tests pass, I had to teach sil-opt how to setup upcoming features
since it did not know how to parse them.

rdar://124100266
2024-03-05 15:15:14 -08:00
Holly Borla
f1cd9cb422 [Test] Remove REQUIRES: asserts from tests that use -swift-version 6. 2024-02-13 07:13:35 -08:00
Pavel Yaskevich
dbf1146963 [Concurrency] NFC: Switch tests to use -strict-concurrency=complete instead of -warn-concurrency 2023-12-08 14:10:51 -08:00
Michael Gottesman
cb46851194 [region-isolation] Rename the experimental feature to RegionBasedIsolation.
This ensures that the pass is called TransferNonSendable but the experimental
feature is RegionBasedIsolation.
2023-10-26 12:01:44 -07:00
Michael Gottesman
0bad8f9b67 [region-isolation] Rename SendNonSendable.cpp -> TransferNonSendable.cpp. 2023-10-26 12:01:44 -07:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Michael Gottesman
026f1735b5 [send-non-sendable] Update concurrency tests so that we run them in all concurrency modes as appropriate.
This means that:

1. In test cases where minimal is the default (swift 5 without
-warn-concurrency), I added RUN lines for targeted, complete, and complete +
sns.

2. In test cases where complete is the default (swift 6, -warn-concurrency,
specified complete with -strict-concurrency), I added a send non-sendable run
line.

In each of these cases, I added additional expected-* lines as appropriate so
the tests can compile in each mode successfully.
2023-08-30 13:40:17 -07:00
Doug Gregor
4116d7a3d7 Rename the -strict-concurrency= options to be more descriptive.
The three options are now:

* `explicit`: Enforce Sendable constraints where it has been explicitly adopted and perform actor-isolation checking wherever code has adopted concurrency. (This is the default)
* `targeted`: Enforce Sendable constraints and perform actor-isolation checking wherever code has adopted concurrency, including code that has explicitly adopted Sendable.
* `complete`: Enforce Sendable constraints and actor-isolation checking throughout the entire module.
2022-04-20 18:17:33 -07:00
Doug Gregor
f404b58b96 Add -strict-concurrency=limited to tests that specifically need it.
This isolates us from changes in the default.
2022-04-20 09:11:10 -07:00
Doug Gregor
dd6a061b29 Only consider a module "strict" if it was compiled in Swift 6 2022-04-19 21:48:35 -07:00
Becca Royal-Gordon
ecdd42f20c Make @preconcurrency import hide sendable variance
When the conformance checker and override checker detect a difference in a function type’s @Sendable attribute that varies in an illegal way, they now check if the protocol/base class was imported with an @preconcurrency import, and either limit the diagnostic or suggest adding @preconcurrency to the import as appropriate.

Completes rdar://91109455.
2022-04-08 13:08:39 -07:00
Becca Royal-Gordon
9cbac44031 Don’t recommend @preconcurrency on audited imports
If a type is explicitly non-Sendable, we don’t want to recommend softening errors with `@preconcurrency import` (even thought that would still work), because these probably represent *real* errors that you ought to fix. And at the extreme end of this, if a module is built with `-warn-concurrency` or `-swift-version 6`, *all* of its types should be treated as though they have explicit sendability, since we assume the entire module has been audited.

(Eventually, we plan to do this at module build time by actually serializing out unavailable conformances rather than by looking at the settings used to build the module, but we aren’t there quite yet.)

Implement this and test it by checking that the preconcurrency sendable tests never recommend adding `@preconcurrency` to an import of `StrictModule`, even when we do the same illegal things with it that cause that remark to be printed for `NonStrictModule`.
2022-04-07 22:29:37 -07:00
Doug Gregor
363f203277 Make @preconcurrency suppress Sendable diagnostics more reliably.
Sendable diagnostics were firing a bit too eagerly because a suppressed
Sendable diagnostic for instance storage of a struct/enum would still
cause that type to not be implicitly Sendable. Additionally, a
`@preconcurrency` import would not always suppress the diagnostic when
there was an explicit Sendable conformance, which it should have.

Fixes rdar://88363542.
2022-02-01 21:31:03 -08:00