Bump availability of Iterable_ and Container protocols to SwiftStdlib 6.4

This is preparing for switching over to the stdlib’s definition of `protocol Iterable`, assuming it will land with macOS 27/iOS 27 etc availability; `Container` is refining `Iterable`, so it needs matching availability.

If `Iterable` won’t ship in Swift 6.4, then we’ll need to bump this again.
This commit is contained in:
Karoy Lorentey committed 2026-07-07 14:22:45 -07:00
1 parent a80c9d1257
commit ff695132ed
66 files changed
+645 -418

No files matched your search

@@ -253,6 +253,7 @@ extension RigidArray {
}
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@inlinable
internal mutating func _append<
Source: Iterable_ & ~Copyable & ~Escapable
@@ -275,6 +276,7 @@ extension RigidArray {
/// - newElements: A container whose contents to copy into the array.
///
/// - Complexity: O(`newElements.count`)
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
@@ -318,6 +320,7 @@ extension RigidArray {
/// - newElements: The new elements to copy into the array.
///
/// - Complexity: O(*m*), where *m* is the length of `newElements`.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
@@ -19,9 +19,9 @@ import ContainersPreview
#if compiler(>=6.2)
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: Iterable_ where Element: ~Copyable {
public typealias BorrowingIterator_ = SpanIterator<Element>
public typealias BorrowingIterator_ = Span<Element>.BorrowingIterator_
@_alwaysEmitIntoClient
@inline(__always)
@@ -35,7 +35,7 @@ extension RigidArray: Iterable_ where Element: ~Copyable {
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: Container where Element: ~Copyable {
@_alwaysEmitIntoClient
@_lifetime(borrow self)
@@ -57,17 +57,17 @@ extension RigidArray: Container where Element: ~Copyable {
}
}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: BidirectionalContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: RandomAccessContainer where Element: ~Copyable {}
#if compiler(>=6.4)
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: MutableContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension RigidArray: RangeReplaceableContainer where Element: ~Copyable {}
#endif
#endif
@@ -122,6 +122,7 @@ extension RigidArray /*where Element: Copyable*/ {
/// just enough capacity to store the contents.
/// - contents: The container whose contents to copy into the new array.
/// The container must not contain more than `capacity` elements.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_ & ~Copyable & ~Escapable>(
@@ -144,6 +145,7 @@ extension RigidArray /*where Element: Copyable*/ {
/// just enough capacity to store the contents.
/// - contents: The container whose contents to copy into the new array.
/// The container must not contain more than `capacity` elements.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_ & Sequence<Element>>(
@@ -330,13 +330,14 @@ extension RigidArray {
}
}
#if !UnstableContainersPreview
@_alwaysEmitIntoClient
package mutating func _insertCollection(
addingCount newCount: Int,
copying items: some Collection<Element>,
at index: Index
) {
// FIXME: Remove this -- RangeReplaceContainer already has this algorithm,
// albeit with stricter availability.
let done: Void? = items.withContiguousStorageIfAvailable { buffer in
precondition(buffer.count == newCount, "Broken Collection: mismatching count")
self.insert(addingCount: buffer.count, at: index) { target in
@@ -353,7 +354,6 @@ extension RigidArray {
}
precondition(it.next() == nil, "Broken Collection")
}
#endif
/// Copies the elements of a collection into this array at the specified
/// position.
@@ -379,9 +379,6 @@ extension RigidArray {
public mutating func insert(
copying items: some Collection<Element>, at index: Int
) {
// FIXME: Remove this -- RangeReplaceContainer already has this algorithm.
// (Note that this would be source breaking while RRC lives in the separate
// ContainersPreview module.)
_insertCollection(addingCount: items.count, copying: items, at: index)
}
}
@@ -121,7 +121,6 @@ extension RigidArray where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if !UnstableContainersPreview
/// Removes and returns the last element of the array, if there is one.
///
/// - Returns: The last element of the array if the array is not empty;
@@ -134,7 +133,6 @@ extension RigidArray where Element: ~Copyable {
if isEmpty { return nil }
return removeLast()
}
#endif
}
#endif
@@ -583,6 +583,7 @@ extension RigidArray {
}
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@inlinable
internal mutating func _replace<
C: Container<Element> & ~Copyable & ~Escapable
@@ -661,6 +662,7 @@ extension RigidArray {
/// - newElements: The new elements to copy into the collection.
///
/// - Complexity: O(`self.count` + `newElements.count`)
@available(SwiftStdlib 6.4, *)
@inlinable
@inline(__always)
public mutating func replace<
@@ -742,6 +744,7 @@ extension RigidArray {
///
/// - Complexity: O(*n* + *m*), where *n* is count of this array and
/// *m* is the count of `newElements`.
@available(SwiftStdlib 6.4, *)
@inlinable
@inline(__always)
public mutating func replace<
@@ -82,6 +82,7 @@ extension RigidSet where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension RigidSet /* where Element: Copyable */ {
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<
@@ -117,6 +118,7 @@ extension RigidSet /* where Element: Copyable */ {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<
@@ -130,6 +132,7 @@ extension RigidSet /* where Element: Copyable */ {
try self._insert(copying: contents)
}
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<
@@ -235,6 +235,7 @@ extension RigidSet /* where Element: Copyable */ {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
package mutating func _insert<
S: Iterable_ & ~Copyable & ~Escapable
@@ -252,6 +253,7 @@ extension RigidSet /* where Element: Copyable */ {
#endif
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
@@ -274,6 +276,7 @@ extension RigidSet /* where Element: Copyable */ {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
@@ -258,6 +258,7 @@ extension UniqueArray {
}
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@inlinable
internal mutating func _append<
Source: Iterable_ & ~Copyable & ~Escapable
@@ -291,6 +292,7 @@ extension UniqueArray {
///
/// - Complexity: O(`newElements.count`), when amortized over many invocations
/// over the same array.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
@@ -346,6 +348,7 @@ extension UniqueArray {
///
/// - Complexity: O(`newElements.count`), when amortized over many invocations
/// over the same array.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func append<
@@ -19,9 +19,9 @@ import ContainersPreview
#if compiler(>=6.2)
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: Iterable_ where Element: ~Copyable {
public typealias BorrowingIterator_ = RigidArray<Element>.BorrowingIterator_
public typealias BorrowingIterator_ = Span<Element>.BorrowingIterator_
@inlinable
public var underestimatedCount_: Int { count }
@@ -35,7 +35,7 @@ extension UniqueArray: Iterable_ where Element: ~Copyable {
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: Container where Element: ~Copyable {
@_alwaysEmitIntoClient
@_lifetime(borrow self)
@@ -51,20 +51,20 @@ extension UniqueArray: Container where Element: ~Copyable {
}
}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: BidirectionalContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: RandomAccessContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: MutableContainer where Element: ~Copyable {}
#if compiler(>=6.4)
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: RangeReplaceableContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
@available(SwiftStdlib 6.4, *)
extension UniqueArray: DynamicContainer where Element: ~Copyable {}
#endif
#endif
@@ -94,6 +94,7 @@ extension UniqueArray /*where Element: Copyable*/ {
/// just enough capacity to store the contents.
/// - contents: A sequence whose contents to copy into the new array.
/// The sequence must not contain more than `capacity` elements.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_ & ~Copyable & ~Escapable>(
@@ -131,6 +132,7 @@ extension UniqueArray /*where Element: Copyable*/ {
/// - capacity: The storage capacity of the new array, or nil to allocate
/// just enough capacity to store the contents.
/// - contents: The container whose contents to copy into the new array.
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public init<Source: Iterable_ & Sequence<Element>>(
@@ -110,7 +110,6 @@ extension UniqueArray where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if !UnstableContainersPreview
/// Removes and returns the last element of the array, if there is one.
///
/// - Returns: The last element of the array if the array is not empty;
@@ -123,7 +122,6 @@ extension UniqueArray where Element: ~Copyable {
if isEmpty { return nil }
return removeLast()
}
#endif
}
#endif
@@ -551,6 +551,7 @@ extension UniqueArray {
///
/// - Complexity: O(*n* + *m*), where *n* is count of this array and
/// *m* is the count of `newElements`.
@available(SwiftStdlib 6.4, *)
@inlinable
@inline(__always)
public mutating func replace<
@@ -641,6 +642,7 @@ extension UniqueArray {
///
/// - Complexity: O(*n* + *m*), where *n* is count of this array and
/// *m* is the count of `newElements`.
@available(SwiftStdlib 6.4, *)
@inlinable
@inline(__always)
public mutating func replace<
@@ -75,6 +75,7 @@ extension UniqueSet where Element: ~Copyable {
extension UniqueSet where Element: Copyable {
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
public init<
S: Iterable_ & ~Copyable & ~Escapable
@@ -94,6 +95,7 @@ extension UniqueSet where Element: Copyable {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
public init<
S: Iterable_ & Sequence<Element>
@@ -131,6 +131,7 @@ extension UniqueSet /* where Element: Copyable */ {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
package mutating func _insert<
S: Iterable_ & ~Copyable & ~Escapable
@@ -149,6 +150,7 @@ extension UniqueSet /* where Element: Copyable */ {
#endif
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
@@ -171,6 +173,7 @@ extension UniqueSet /* where Element: Copyable */ {
}
#if UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<