Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0][stdlib] Start adopting noncopyable generics in the stdlib #72436

Merged
merged 55 commits into from
Mar 20, 2024

Conversation

lorentey
Copy link
Member

This is a cherry-pick of #71688.

Relax the copyability requirement on the type parameters of several crucial stdlib generic types and functions:

  • struct MemoryLayout<T: ~Copyable>
  • struct UnsafePointer<Pointee: ~Copyable>
  • struct UnsafeMutablePointer<Pointee: ~Copyable>
  • struct UnsafeBufferPointer<Element: ~Copyable>
  • struct UnsafeMutableBufferPointer<Element: ~Copyable>
  • enum Optional<Wrapped: ~Copyable>: ~Copyable
  • enum Result<Success: ~Copyable, Failure>: ~Copyable
  • func swap<T: ~Copyable>
  • func withExtendedLifetime<T: ~Copyable, R: ~Copyable>
  • func withUnsafeTemporaryAllocation<T: ~Copyable, R> (generalizing R is a to do item for later)
  • class ManagedBuffer<Header, Element: ~Copyable> (generalizing Header is a to do for later)
  • struct ManagedBufferPointer<Header, Element: ~Copyable> (ditto)

Except for Optional and Result, making the parameter non-copyable will not affect the copyability of the type itself.

[stdlib] MemoryLayout: Update Swift version numbers

[stdlib] MemoryLayout: Actually hide legacy ABI
… types

[stdlib] Pull back @_aeic on pointer → integer conversions

[stdlib] UnsafeMutablePointer.allocate: Fix thinko

[stdlib] Disable support for noncopyable pointees on some pointer operations

We have to temporarily pull back support for noncopyable pointees for UnsafeMutablePointer.initialize(to:), .moveInitialize, .moveUpdate, as the builtins they’re calling are no longer accepting such types.

These will return following a builtin audit.

[stdlib] Remove workarounds for certain builtins not supporting noncopyable use

swiftlang#71733 fixed this!

[stdlib] Update FIXME

[stdlib] UnsafePointer: Update Swift version numbers

[stdlib] UnsafePointer: Actually hide legacy ABI

[stdlib] Remove workaround for U[M]BP.withMemoryRebound
- Enable BorrowingSwitch feature within the stdlib
- ExpressibleByNilLiteral: Add retroactive support for noncopyable conforming types
- Optional: draft an API surface for noncopyable payloads

[stdlib] Oops, the ExpressibleByNilLiteral conformance kept its implicit copyability
…P.isEmpty

These `isEmpty` descriptors got upgraded from Collection extensions to direct implementations, and they now come with property descriptors (despite being `@_alwaysEmitIntoClient`).
…on facility

Generalizing the result type is not yet possible, but T works!
Header is tricky, but it’s on the TODO list for later.
The missing symbols aren’t load bearing, so this should be fine as a temporary workaround.
lorentey and others added 24 commits March 19, 2024 11:18
It’s a caseless enum, but there’s no reason to change this aspect of it.
…events toolchain builds from succeeding"

This reverts commit 0266c6d.
[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice
…rk when using Optional and other stdlib features
@lorentey lorentey requested a review from a team as a code owner March 19, 2024 20:25
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci build toolchain macOS platform

@lorentey lorentey merged commit c4e726a into swiftlang:release/6.0 Mar 20, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants