Commit Graph

21665 Commits

Author SHA1 Message Date
Karoy Lorentey
463f35531c [stdlib] ObjectIdentifier: Work around issue with generalized existentials 2025-03-24 12:15:49 -07:00
Karoy Lorentey
4db7b7c69d [stdlib] Note some syntactic wrinkles 2025-03-24 12:15:47 -07:00
Karoy Lorentey
a52c060924 [stdlib] dependsOn → @lifetime 2025-03-24 12:15:46 -07:00
Karoy Lorentey
b9d7206028 [stdlib] Start generalizing Result
- Allow nonescapable `Success` types
- Generalize `Sendable` conformance
- Generalize `Result.mapError`
- Generalize `Result.get()`

Do not generalize `Result.init(catching:)` or higher-order functions involving the success value: they cannot possibly work correctly yet.
2025-03-24 12:15:44 -07:00
Karoy Lorentey
0d926834c8 [stdlib] ObjectIdentifier: Also allow nonescapable types 2025-03-24 12:15:44 -07:00
Karoy Lorentey
a0751a4a89 [stdlib] ObjectIdentifier: Allow initialization from metatypes of noncopyable types 2025-03-24 12:15:43 -07:00
Karoy Lorentey
fb3455eccf [stdlib] Generalize withExtendedLifetime; add extendLifetime 2025-03-24 12:15:42 -07:00
Karoy Lorentey
201430522b [stdlib] Generalize ManagedBufferPointer.== 2025-03-24 12:15:41 -07:00
Karoy Lorentey
351adc7d4a [stdlib] Enable NonescapableTypes 2025-03-24 12:15:41 -07:00
Karoy Lorentey
696bbac938 [stdlib] unsafeBitCast: generalize for ~Escapable input types 2025-03-24 12:15:39 -07:00
Karoy Lorentey
9b322e3e8e [stdlib] Optional: Allow non-escapable wrapped types 2025-03-24 12:15:38 -07:00
Karoy Lorentey
9d86a45af9 [stdlib] ExpressibleByNilLiteral: allow ~Escapable conformers 2025-03-24 12:15:37 -07:00
Karoy Lorentey
db92d2b915 [stdlib] Generalize MemoryLayout for ~Escapable types 2025-03-24 12:15:33 -07:00
Tony Allevato
815c3e8a6e Merge pull request #80238 from alexfh/patch-1
Fix a compilation error with LLVM 21
2025-03-24 14:54:51 -04:00
Mike Ash
6a383b270e [Runtime] Ignore some global constructor warnings.
We have a few constructor functions that aren't wrapped in SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN/SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END and which have started to produce warnings in a new clang version. Explicitly allow these constructors by adding those.

rdar://147703947
2025-03-24 12:43:03 -04:00
Guillaume Lessard
c21de062bb Merge pull request #78561 from glessard/rdar137710901-span-properties-prototype
[SE-0456] Span properties (part 1)
2025-03-24 08:47:47 -07:00
Holly Borla
498d7ccc17 Merge pull request #80187 from hborla/task-macro-improvements
[Macros] Update the name and argument list for the `@Task` function body macro.
2025-03-24 08:46:32 -07:00
Alastair Houghton
b032d704ed Merge pull request #80214 from al45tair/rename-unsafefirst
[Backtracing] Rename `unsafeFirst` to `consumingFirst`.
2025-03-24 14:32:44 +00:00
Alexander Kornienko
dd83d1e1e0 Fix a compilation error
This fixes a `copy constructor must pass its first argument by reference` compilation error when compiled with a recent enough Clang (after fe0d3e3764)
2025-03-24 11:46:10 +01:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Saleem Abdulrasool
9354fd91d1 Merge pull request #80200 from Steelskin/fabrice/restore-float-fenv-modules
Put float and stddef back inside the ucrt module
2025-03-22 20:36:57 -07:00
Guillaume Lessard
ebbec5030f Merge pull request #80217 from glessard/stdlibUnittest-wasi-skip
[StdlibUnittest] add a TestRunPredicate for WASI
2025-03-22 17:39:00 -07:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Guillaume Lessard
7b035936e4 [temporary] disable spans over inline elements 2025-03-21 17:26:29 -07:00
Guillaume Lessard
d5cb7ddf64 [stdlib] changes to lifetime annotations
Changes to lifetime annotations implemented in https://github.com/swiftlang/swift/pull/80064
2025-03-21 17:24:45 -07:00
Guillaume Lessard
df33b83c78 [StdlibUnittest] add a TestRunPredicate for WASI 2025-03-21 15:47:25 -07:00
Alastair Houghton
75b9c8f2cf [Backtracing] Rename unsafeFirst to consumingFirst.
This seems like a better name.
2025-03-21 21:18:31 +00:00
Gábor Horváth
ebeee4d716 Merge pull request #80163 from swiftlang/gaborh/vector-span-property
[cxx-interop] Add span property to std::vector
2025-03-21 19:00:34 +00:00
Saleem Abdulrasool
90d9ce76ba Concurrency: handle android similar to Linux
Android should use the dispatch based, Linux platform executor. However,
Android reports as `os(Android)` rather than `os(Linux)`. This adjusts
the condition to ensure that we have a platform executor factory for
Android.
2025-03-21 11:00:08 -07:00
Fabrice de Gans
d5ea19405d Put float and stddef back inside the ucrt module
These were split out in #79751. However, this split is not needed for
these. Furthermore, modulemaps have bugs when it comes to re-exporting
some modules, resulting in missing exports.
2025-03-21 10:01:01 -07:00
Holly Borla
bac0a10ae2 [Macros] Update the name and argument list for the function body macro
that wraps a function or closure body in a new top-level task.
2025-03-21 06:21:45 -07:00
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Dario Rexin
35a44e5168 [Concurrency] Fix templated code in Task+startSynchronously.swift (#80100)
* [Concurrency] Fix templated code in Task+startSynchronously.swift

rdar://147348183

The gyb code always dropped the `throws` modifier, no matter which case was being processed.

* Update Task+startSynchronously.swift.gyb

* Fix abi tests
2025-03-20 18:29:31 -07:00
Dave Lee
6ca8e0d502 [Concurrency] Change signposts to use decimal format for task ids (#80154)
Change task ids to be formatted using decimal instead of hex.

An example of previous signposts:

```
task=e resumefn=0x2807722bc jobPriority=0 isChildTask=0, isFuture=1 isGroupChildTask=0 isAsyncLetTask=0 parent=0 group=0x0 asyncLet=0x0
```

this will now show `task=14` instead of `task=e`
2025-03-20 13:23:37 -07:00
Gabor Horvath
3d6c714cd6 [cxx-interop] Add span property to std::vector
rdar://146944876
2025-03-20 16:15:06 +00:00
Mike Ash
1e265c24d7 Merge pull request #80096 from mikeash/task-group-cancellation-lock-fix
[Concurrency] Fix a race when using cancelAll on a task group concurrently with child tasks being removed.
2025-03-20 11:53:31 -04:00
Saleem Abdulrasool
43ec13a65b Merge pull request #80151 from Steelskin/fabrice/restore-ucrt-legacy-stdio-def
Restore legacy_stdio_definitions in ucrt.modulemap
2025-03-19 21:57:15 -07:00
Fabrice de Gans
7a965cee00 Restore legacy_stdio_definitions in ucrt.modulemap
This was removed in #79751 but is required in some cases.
2025-03-19 16:51:38 -07:00
Andrew Trick
955d089a90 CxxSpanReturnThunkBuilder: use _cxxOverrideLifetime(_:copying:)
Do not rely on the @_unsafeNonescapableResult attribute. That attribute is only
for temporarily working around bugs! And it only affects lifetime diagnostics within
the function. It has no affect on the caller's diagnostics, so it won't solve
this problem:

func macroGeneratedThunk() -> CxxSpan<Int> {
  return _unsafeRemoveLifetime(Span...)
}

We cannot simply add @_unsafeRemoveLifetime to the thunk, because SwiftSyntax
does not natively support the attribute. We don't want to add SwiftSyntax
support because this attribute will never be supported syntax!

Instead, use `_overrideLifetime` copying the `Void` type to remove a dependency:

func macroGeneratedThunk() -> CxxSpan<Int> {
  return _cxxOverrideLifetime(Span..., copying: ())
}
2025-03-19 11:59:05 -07:00
Andrew Trick
e91981266b Update CXXSpan for strict @lifetime 2025-03-19 11:59:04 -07:00
Andrew Trick
c6116be7b5 Update stdlib source with explicit @lifetime(copy self) 2025-03-19 11:59:04 -07:00
Andrew Trick
411a65be2e Add @lifetime annotation to RawSpan.init() and Span.init()
These empty initializers have @lifetime(immortal).
2025-03-19 11:59:04 -07:00
Egor Zhdan
02dfe26f8f Merge pull request #80090 from swiftlang/egorzhdan/std-string-interpolation
[cxx-interop] Conform `std::string` to `ExpressibleByStringInterpolation`
2025-03-19 18:28:56 +00:00
Mike Ash
953a7a5b74 [Runtime] Include size/alignment in allocation failure fatal error message.
It's hard to tell why a crash occurred with just "Could not allocate memory." Modify the message to include the size/alignment, which will help distinguish between an actual lack of memory and a request for an excessively large allocation.

While we're in there, add \n to a bunch of other fatal error helper functions that didn't have it.
2025-03-19 11:18:43 -04:00
Alastair Houghton
c20aa667f2 [Concurrency] Disable various things for task-to-thread model.
When in task-to-thread model concurrency mode, there is no `MainActor`
and we cannot use `ExecutorJob`, so disable various things.

rdar://141348916
2025-03-19 11:15:00 +00:00
Mike Ash
38c4fce1a8 [Concurrency] Fix a race when using cancelAll on a task group concurrently with child tasks being removed.
_swift_taskGroup_cancelAllChildren relies on there being no concurrent modification when called from the owning task, but this is not guaranteed.

Rearrange things to always take the owning task's status record lock when walking the group's children. Split _swift_taskGroup_cancelAllChildren into two functions, one which assumes/requires the lock is already held, and one which acquires the lock. We don't have the owning task in this case, but we can either get it from the current task, or by looking at the parent of the child task we're working on.

rdar://147172991
2025-03-18 14:52:07 -04:00
Alastair Houghton
0da95eb20d [Concurrency] Fix some warnings, use typed throws.
Fix a couple of `unsafe` warnings.

Also update `withUnsafeExecutorPrivateData` to use typed throws instead of
`rethrow`.

rdar://141348916
2025-03-18 18:37:31 +00:00
Alastair Houghton
fb0396c509 [Concurrency] Fall back to allocating from the heap, fix a test.
`CooperativeExecutor` should fall back to heap allocations if the task
allocator isn't available when it's enqueuing delayed jobs.

Also, remove the reference to `DispatchGlobalExecutor` from the
custom executor test.

rdar://141348916
2025-03-18 17:59:57 +00:00
Alejandro Alonso
25b10ebf76 Merge pull request #78092 from Azoy/enumerated-collection
[stdlib] Conditionally conform EnumeratedSequence to Collection(s)
2025-03-18 09:24:08 -07:00
Fabrice de Gans
5e3bd9f90b Merge pull request #79751 from Steelskin/fabrice/update-ucrt-modulemap
Update ucrt.modulemap for Windows SDK 10.0.26100
2025-03-18 09:04:24 -07:00