-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[stdlib] Start adopting noncopyable generics in the stdlib #71688
Conversation
@swift-ci Please Build Toolchain macOS Platform |
// This unavailable implementation uses the expected mangled name | ||
// of `withMemoryRebound<T, Result>(to:capacity:_:)`, and provides | ||
// an entry point for any binary linked against the stdlib binary | ||
// for Swift 5.6 and older. | ||
@available(*, unavailable) | ||
@available(swift, obsoleted: 5.11) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth putting this in LegacyABI.swift
instead to clear up this file a little? (You don't have to, just adding a suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but let's wait for the dust to settle a bit.
4d85587
to
1681dcd
Compare
@swift-ci please build toolchain macOS platform |
1681dcd
to
8ef149f
Compare
@swift-ci please build toolchain macOS platform |
1 similar comment
@swift-ci please build toolchain macOS platform |
405477a
to
d077efa
Compare
@swift-ci please build toolchain macOS platform |
d077efa
to
73ffc13
Compare
@swift-ci please build toolchain macOS platform |
3 similar comments
@swift-ci please build toolchain macOS platform |
@swift-ci please build toolchain macOS platform |
@swift-ci please build toolchain macOS platform |
4cf3691
to
77b907e
Compare
@swift-ci please build toolchain macOS platform |
77b907e
to
0dff899
Compare
@swift-ci please build toolchain macOS platform |
The shame! |
0dff899
to
f70dd33
Compare
@swift-ci test |
@swift-ci please build toolchain macOS platform |
f70dd33
to
e6dd049
Compare
@swift-ci please build toolchain macOS platform |
@swift-ci smoke test |
…s a suppressible feature
@swift-ci smoke test |
@swift-ci test |
@swift-ci benchmark |
@swift-ci built toolchain macOS |
Interesting, locally I'm seeing an extra xpass that wasn't there at the last run:
|
@swift-ci smoke test |
@swift-ci test |
@swift-ci benchmark |
@swift-ci build toolchain macOS |
Oh man, this got caught by the old duplicate allow-list entries thing again. Resolution is easy, it's just a shame these tests are Intel-only.
|
Amusing preprocessor warning:
|
@swift-ci test |
@swift-ci smoke test |
@swift-ci benchmark |
@swift-ci build toolchain macOS |
// FIXME(NCG): Shouldn't this be also an error? | ||
var moveOnly: MoveOnlyStruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just diagnose one property and stop. I guess we could diagnose all of the noncopyable properties preventing conformance 🤷🏼
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>
(generalizingR
is a to do item for later)class ManagedBuffer<Header, Element: ~Copyable>
(generalizingHeader
is a to do for later)struct ManagedBufferPointer<Header, Element: ~Copyable>
(ditto)Except for
Optional
andResult
, making the parameter non-copyable will not affect the copyability of the type itself.Notes, limitations:
_Pointer
protocol'sPointee
associated type is no longer required to be copyable. This is a source-breaking change._Pointer
is not public API, so we're hoping it'll be okay.~Copyable
clauses change the mangling of generic functions defined over specific types (as opposed to protocols). This PR uses the new@_preInverseGenerics
attribute to avoid having to duplicate existing entry points.UnsafeMutablePointer.initialize(to:)
was originally defined to take a__shared
argument. This PR changes its new version to take aconsuming
parameter.UnsafeMutableBufferPointer.initialize(at:to:)
andUnsafeMutableRawPointer.initialize(as:to:)
.Result.mapError(_:)
andResult.get()
are now redefined as consuming methods.UnsafeCxx*Iterator
protocols and changing whatever needed to be changed to support non-copyable pointees, with no regards to compatibility.