Skip to content

[stdlib] API additions for basic noncopyable primitives #73807

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

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented May 21, 2024

This PR implements the stdlib API additions introduced by SE-0437:

  • Add exchange(_:with:)
  • Add Optional.take()
  • Add Unsafe[Mutable]BufferPointer.extracting(_:)
  • Finish generalizing withExtendedLifetime
  • Radically simplify the implementation of swap(_:_:)

@lorentey lorentey added the swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal label May 21, 2024
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci test source compatibility

@lorentey
Copy link
Member Author

@swift-ci build toolchain

@lorentey
Copy link
Member Author

@swift-ci test

@lorentey

This comment was marked as outdated.

@lorentey
Copy link
Member Author

@swift-ci test source compatibility

@lorentey
Copy link
Member Author

@swift-ci build toolchain

@lorentey lorentey added swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process and removed swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review labels Jun 3, 2024
@lorentey lorentey force-pushed the stdlib-noncopyable-additions branch from fc1ddd2 to 3df540d Compare June 6, 2024 00:34
@lorentey lorentey marked this pull request as ready for review June 6, 2024 00:53
@lorentey lorentey force-pushed the stdlib-noncopyable-additions branch from 3df540d to c75ad47 Compare June 6, 2024 00:55
@lorentey
Copy link
Member Author

lorentey commented Jun 6, 2024

@swift-ci test

Builtin.initialize(tmp, p2)
let temp = consume a
a = consume b
b = consume temp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@@ -232,7 +232,7 @@ extension Optional where Wrapped: ~Copyable {
) throws(E) -> U? {
#if compiler(>=6.0) && $NoncopyableGenerics
switch self {
case .some(_borrowing y):
case .some(let y):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming these changes are in reaction to warnings about _borrowing being deprecated. I had to change these to use the deprecated spellings intentionally in order to ensure that the standard library's .swiftinterface is still buildable with the older compiler versions that we support. Until we drop support for those older compiler versions these warnings cannot be addressed I'm afraid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local testing on release/6.0 indicates we're good -- those old compilers appear to accept this PR (or rather, the sibling PR #73810) as is, with no changes. Switching back from _borrowing to let may actually be working in our favor here. Lucky escape!

lorentey added 2 commits June 7, 2024 14:09
- Add `exchange(_:with:)`
- Add `Optional.take()`
- Add `Unsafe[Mutable]BufferPointer.extracting(_:)`
- Finish generalizing `withExtendedLifetime`
- Radically simplify the implementation of `swap(_:_:)`
@lorentey lorentey force-pushed the stdlib-noncopyable-additions branch from c75ad47 to f2dc894 Compare June 7, 2024 23:10
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci build toolchain

@lorentey
Copy link
Member Author

@swift-ci test source compatibility

@lorentey
Copy link
Member Author

All known issues have been addressed. This is technically ready to merge pending favorable CI outcome.

However, the PR includes a couple of tiny amendments to SE-0437; I'm temporarily holding off from landing this until the LSG has had a chance to discuss swiftlang/swift-evolution#2489.

I keep forgetting that `some RangeExpression<Element>` does not cover the `UnboundedRange` form.
@lorentey lorentey force-pushed the stdlib-noncopyable-additions branch from 273949f to 9d947e4 Compare June 17, 2024 22:03
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci build toolchain

@lorentey
Copy link
Member Author

@swift-ci test source compatibility

@lorentey
Copy link
Member Author

Some of the toolchains builds will fail as #74486 has not landed yet.

@lorentey lorentey merged commit 470a04c into swiftlang:main Jun 20, 2024
8 of 10 checks passed
@lorentey lorentey deleted the stdlib-noncopyable-additions branch June 20, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants