-
Notifications
You must be signed in to change notification settings - Fork 188
[SE-0456, -0467] Data+Span+MutableSpan #1276
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please test |
@swift-ci please test |
The Windows test https://ci-external.swift.org/job/swift-foundation-pull-request-windows/717/ ran with |
@swift-ci please test macOS platform |
@@ -111,7 +111,8 @@ list(APPEND _SwiftFoundation_versions | |||
list(APPEND _SwiftFoundation_availability_names | |||
"FoundationPreview" | |||
"FoundationPredicate" | |||
"FoundationPredicateRegex") | |||
"FoundationPredicateRegex" | |||
"FoundationSpan") |
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.
Why do we need a new availability macro?
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.
This requires a 6.2 toolchain to get the symbols, and won't have the same range of deployment targets as any of the others, as far as I can tell.
@@ -49,6 +49,7 @@ | |||
#endif | |||
|
|||
internal import _FoundationCShims | |||
import Builtin |
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.
Should this be internal import Builtin
?
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.
The Builtin module is public by virtue of being inlined all over the standard library; in this file we're calling it from opaque code, so there's nothing being reexported at all.
@@ -604,6 +605,7 @@ internal final class __DataStorage : @unchecked Sendable { | |||
|
|||
@frozen | |||
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *) | |||
@_addressableForDependencies |
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.
Any ABI or source stability impact for this?
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.
There's no source stability impact. It only changes the mangling for functions that try to establish a lifetime dependence on Data
, and there are none of those until we publish these span
properties.
@@ -2198,7 +2200,105 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect | |||
public func withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType { | |||
return try _representation.withUnsafeBytes(body) | |||
} | |||
|
|||
|
|||
#if compiler(>=6.2) |
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 only support building this with the 6.2 compiler in the first place.
@@ -2848,3 +2948,62 @@ extension Data : Codable { | |||
} | |||
} | |||
} | |||
|
|||
#if compiler(>=6.2) | |||
// TODO: remove once _overrideLifetime is public in the standard library |
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.
When will that happen?
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.
This is the PR: swiftlang/swift#81225
I presume that this could be in a nightly snapshot within a week.
Add the properties
span
,mutableSpan
,bytes
andmutableBytes
toData
, as proposed in SE-0456 and SE-0467.Addresses rdar://137711067