Commit Graph

7802 Commits

Author SHA1 Message Date
Guillaume Lessard
ecebaa591e [stdlib] move span properties of array types
…to a more logical spot in each of their files
2025-03-27 14:52:08 -07:00
Guillaume Lessard
90684a87a3 [stdlib] add missing unsafe annotations 2025-03-27 13:34:34 -07:00
Guillaume Lessard
5a087d1190 [stdlib] annotate unsafe initializers 2025-03-27 13:34:34 -07:00
Guillaume Lessard
9553982253 [stdlib] use the internal unsafe-unwrap 2025-03-27 13:34:34 -07:00
Guillaume Lessard
4a78667db8 [stdlib] tweaks to MutableRawSpan 2025-03-27 13:34:33 -07:00
Guillaume Lessard
b39ee18f31 [stdlib] tweaks to MutableSpan 2025-03-27 13:34:33 -07:00
Guillaume Lessard
cbbe5df00b [stdlib] add unsafe annotations 2025-03-27 13:34:33 -07:00
Guillaume Lessard
484905b42d [stdlib] add extracting() to MutableSpan and MutableRawSpan 2025-03-27 13:34:32 -07:00
Guillaume Lessard
f214ef29d0 [stdlib] small spelling fixes 2025-03-27 13:34:32 -07:00
Guillaume Lessard
2fa2391c28 [stdlib] remove 2 symbols 2025-03-27 13:34:32 -07:00
Guillaume Lessard
30a3eaec4f [stdlib] add MutableSpan and MutableRawSpan 2025-03-27 13:30:13 -07:00
Karoy Lorentey
86f6c29e34 [stdlib] Temporarily reinstate original ObjectIdentifier.init as public
The new generalization sometimes causes a runtime hang that I’m still analyzing. The original declaration should be considered more specific for preexisting use cases, eliminating the source compatibility issue.
2025-03-27 11:24:31 -07:00
Ben Rimmington
2f9f5ffd85 [stdlib] Update element constraints of Span 2025-03-26 22:32:08 +00:00
Doug Gregor
0d296b5f89 [Standard library] Address remaining memory-safety warnings 2025-03-25 10:57:17 -07:00
Dario Rexin
2f4a8a8658 Merge pull request #80272 from glessard/rdar137710901-span-properties-prototype
[temporary] disable spans over inline elements
2025-03-25 09:02:14 -07:00
Guillaume Lessard
e5c7dfc430 [temporary] disable spans over inline elements
unblocks building a debug-mode standard library
2025-03-25 08:55:53 -07:00
Michael Chiu
617a701afc Arm64 FreeBSD toolchain should use 'aarch64' arch 2025-03-24 18:46:32 -04:00
Slava Pestov
b0627e28a2 stdlib: Build with -previous-module-installname-map-file on Apple platforms 2025-03-24 17:56:45 -04:00
Slava Pestov
fa41c70b7f stdlib: Symlink libswiftCore.dylib to libswiftCompatibilitySpan.dylib 2025-03-24 17:56:44 -04:00
Slava Pestov
5c1b20d2bc stdlib: Build libswiftCompatibilitySpan.dylib compatibility shim
This dynamic library contains a copy of the standard library's
exported entry points for the Span and RawSpan types. This will
allow backward deployment of code that uses those new types.
2025-03-24 17:56:44 -04:00
Karoy Lorentey
5bc723d703 [stdlib] Adjust lifetime declarations 2025-03-24 12:16:20 -07:00
Karoy Lorentey
192b404947 [stdlib] Work around ~Escapable breaking Optional.init syntax 2025-03-24 12:16:19 -07:00
Karoy Lorentey
b17a8d493d Generalize Optional._consumingUncheckedUnwrapped()
This is just to round things out — this internal function was sticking out from the public interfaces. No stdlib code needs this generalization yet, but I see no reason to delay it.
2025-03-24 12:16:18 -07:00
Karoy Lorentey
dc5e9f585f Add some missing @lifetime attributes
We were relying on infererred lifetimes by accident — it’s better to spell things out for now.
2025-03-24 12:16:17 -07:00
Karoy Lorentey
21169d12e8 Reinstate generalization of Optional.unsafelyUnwrapped 2025-03-24 12:16:16 -07:00
Karoy Lorentey
480f87027d [stdlib] Mark Unsafe*BufferPointer.indices as safe 2025-03-24 12:16:15 -07:00
Karoy Lorentey
6ead0d8cd6 [stdlib] Postpone generalizing Result.flatMapError 2025-03-24 12:16:13 -07:00
Karoy Lorentey
40d2cda28c [stdlib] Properly generalize metatype comparisons 2025-03-24 12:16:12 -07:00
Karoy Lorentey
c2d33b4f71 [stdlib] Take out generalization of Optional.unsafelyUnwrapped for now 2025-03-24 12:16:08 -07:00
Karoy Lorentey
26176cc929 [stdlib] Allow metatypes of noncopyable/nonescapable types to get compared 2025-03-24 12:16:08 -07:00
Karoy Lorentey
eba00922c3 [stdlib] Properly generalize ObjectIdentifier.init(Any.Type)
With Slava’s fix in https://github.com/swiftlang/swift/pull/79647, we can now refer to generalized type existentials in ABI stable code.
2025-03-24 12:16:07 -07:00
Karoy Lorentey
801385ad49 [stdlib] Generalize the signature of type(of:)
`func type(of:)` is wholly magical, but it does have a signature in the stdlib (mostly for documentation purposes), and it currently requires its input to be copyable and escapable.

`type(of:)` is actually usable on all entities, so it seems desirable to update its signature to reflect this.

Additionally, this seems like a good time to mark its exported symbol obsolete. I don’t expect anyone would ever link to it (unless there is/was a bug), so in theory we could also silently remove it — but explicitly marking it as legacy ABI seems the least risky option.
2025-03-24 12:16:06 -07:00
Karoy Lorentey
3c133d56c1 Revert "[stdlib] unsafeBitCast: generalize for ~Escapable input types"
This reverts commit 0d7cab589f1a7fbcb988b28aec50db768e018539.
2025-03-24 12:16:03 -07:00
Karoy Lorentey
8a7fcc3bbf [stdlib] Update syntax for conditional conformances to invertable protocols 2025-03-24 12:16:02 -07:00
Karoy Lorentey
538f2742ef [stdlib] Roll back generalization of the nil-coalescing operator ??
We cannot currently express its proper lifetime semantics: its result’s lifetime should depend on the intersection of the lifetime of the left argument and the lifetime of the result of the right argument.

`@lifetime(optional, defaultValue.result)` is what we want, but the `.result` part is not currently expressible. (Tying the dependency on the closure argument itself may be a viable option, but we aren’t confident enough to ship it like that yet.)
2025-03-24 12:16:01 -07:00
Karoy Lorentey
96fd749ecc [stdlib] Generalize unsafe buffer pointer operations on Slice
`Slice` continues to require `Element` to be copyable, so this is limited to`moveInitializeMemory`, `bindMemory`, `withMemoryRebound` and `assumingMemoryBound`. Generalizing these restores parity with the corresponding operations on unsliced buffer pointers, and reduces the need to artificially rebase the slices only to call these.
2025-03-24 12:16:01 -07:00
Karoy Lorentey
b7b75aeace [stdlib] Generalize Optional.unsafelyUnwrapped 2025-03-24 12:15:56 -07:00
Karoy Lorentey
cf35c65863 [stdlib] Generalize Unsafe[Mutable]BufferPointer.indices 2025-03-24 12:15:55 -07:00
Karoy Lorentey
0e55d96a22 [stdlib] Generalize Optional.take(), ?? and nil comparisons 2025-03-24 12:15:52 -07:00
Karoy Lorentey
84b63956bf [stdlib] Generalize Optional’s “some” initializer 2025-03-24 12:15:51 -07:00
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