[BasicContainers] Finalize requirements for hashed containers

- UnstableNoncopyableKeys → UnstableHashedContainers
- Delete the GeneralizedEquatable and GeneralizedHashable protocols, replacing them with the standard generalizations in the 6.4 stdlib
- Require Swift 6.4 for {Rigid,Unique}{Set,Dictionary}.
This commit is contained in:
Karoy Lorentey committed 2026-03-03 16:01:45 -08:00
1 parent 01661b6694
commit ffdc48e67e
58 files changed
+137 -207

No files matched your search

-1
View File
@@ -49,7 +49,6 @@ target_sources(${module_name} PRIVATE
"UniqueArray/UniqueArray+Insertions.swift"
"UniqueArray/UniqueArray+Removals.swift"
"UniqueArray/UniqueArray+Replacements.swift"
"HashTable/ProtocolGeneralizations.swift"
"HashTable/_HTable.swift"
"HashTable/_HTable+Bitmap.swift"
"HashTable/_HTable+Bucket.swift"
@@ -1,117 +0,0 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
/// This is a stand-in for the generalization of Equatable as described in SE-0499.
/// This is a temporary protocol that will be deprecated and later removed
/// when the official generalization becomes widely available.
public protocol GeneralizedEquatable: ~Copyable, ~Escapable {
/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
static func == (lhs: borrowing Self, rhs: borrowing Self) -> Bool
}
/// This is a stand-in for the generalization of Hashable as described in SE-0499.
/// This is a temporary protocol that will be deprecated and later removed
/// when the official generalization becomes widely available.
public protocol GeneralizedHashable: GeneralizedEquatable, ~Copyable, ~Escapable {
/// Hashes the essential components of this value by feeding them into the
/// given hasher.
///
/// Implement this method to conform to the `Hashable` protocol. The
/// components used for hashing must be the same as the components compared
/// in your type's `==` operator implementation. Call `hasher.combine(_:)`
/// with each of these components.
///
/// - Important: In your implementation of `hash(into:)`,
/// don't call `finalize()` on the `hasher` instance provided,
/// or replace it with a different instance.
/// Doing so may become a compile-time error in the future.
///
/// - Parameter hasher: The hasher to use when combining the components
/// of this instance.
func hash(into hasher: inout Hasher)
/// The temporary substitute to `Hashable._rawHashValue(seed:)`, the raw
/// top-level hashing interface. Some standard library types (mostly
/// primitives) specialize this to eliminate small resiliency overheads. (This
/// only matters for tiny keys.)
///
/// We avoid using the stdlib name as the stdlib's default implementation is
/// overwhelmingly preferable but it isn't (easily) reimplementable outside
/// of the stdlib.
///
/// This will be replaced by the actual `Hashable` method when its
/// generalization ships.
func _rawHashValue_temp(seed: Int) -> Int
}
extension GeneralizedHashable where Self: ~Copyable & ~Escapable {
@inlinable
public func _rawHashValue_temp(seed: Int) -> Int {
var hasher = Hasher()
hasher.combine(seed)
self.hash(into: &hasher)
return hasher.finalize()
}
}
extension GeneralizedHashable where Self: Hashable {
@inlinable
public func _rawHashValue_temp(seed: Int) -> Int {
_rawHashValue(seed: seed)
}
}
extension GeneralizedHashable where Self: ~Copyable & ~Escapable {
/// The hash value.
///
/// Hash values are not guaranteed to be equal across different executions of
/// your program. Do not save hash values to use during a future execution.
@_alwaysEmitIntoClient
@inline(__always)
public var hashValue: Int {
_rawHashValue_temp(seed: 0)
}
}
extension Int: GeneralizedHashable {}
extension Int8: GeneralizedHashable {}
extension Int16: GeneralizedHashable {}
extension Int32: GeneralizedHashable {}
extension Int64: GeneralizedHashable {}
@available(SwiftStdlib 6.0, *)
extension Int128: GeneralizedHashable {}
extension UInt: GeneralizedHashable {}
extension UInt8: GeneralizedHashable {}
extension UInt16: GeneralizedHashable {}
extension UInt32: GeneralizedHashable {}
extension UInt64: GeneralizedHashable {}
@available(SwiftStdlib 6.0, *)
extension UInt128: GeneralizedHashable {}
extension Float: GeneralizedHashable {}
extension Double: GeneralizedHashable {}
@available(SwiftStdlib 5.7, *)
extension Duration: GeneralizedHashable {}
extension String: GeneralizedHashable {}
extension Substring: GeneralizedHashable {}
extension Character: GeneralizedHashable {}
extension Bool: GeneralizedHashable {}
extension UnsafePointer: GeneralizedHashable {}
extension UnsafeMutablePointer: GeneralizedHashable {}
#endif
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -15,7 +15,7 @@ import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary {
@@ -55,7 +55,7 @@ extension RigidDictionary {
}
@available(SwiftStdlib 5.0, *)
extension RigidDictionary: GeneralizedEquatable where Value: GeneralizedEquatable { // Should be Equatable
extension RigidDictionary: Equatable where Value: Equatable {
@inlinable
public static func ==(left: borrowing Self, right: borrowing Self) -> Bool {
left.isEqual(to: right, by: ==)
@@ -14,10 +14,10 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary: GeneralizedHashable where Value: GeneralizedHashable { // Should be Hashable
extension RigidDictionary: Hashable where Value: Hashable { // Should be Hashable
@inlinable
public func hash(into hasher: inout Hasher) {
var commutativeHash = 0
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -54,7 +54,7 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
let bucket = self._keys._table.insertNew_Large(
hashValue: hashValue,
hashGenerator: {
keys[$0]._rawHashValue_temp(seed: seed)
keys[$0]._rawHashValue(seed: seed)
},
swapper: { bucket in
swap(&key, &keys[bucket])
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -32,7 +32,7 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
self._keys._table.resolveHole(
at: bucket,
hashGenerator: {
keys[$0.offset]._rawHashValue_temp(seed: seed)
keys[$0.offset]._rawHashValue(seed: seed)
},
mover: {
(keys + $1.offset).initialize(to: (keys + $0.offset).move())
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -67,10 +67,10 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
selector: {
srcKey = sourceKeys + $0.offset
srcValue = sourceValues + $0.offset
return srcKey.pointee._rawHashValue_temp(seed: seed)
return srcKey.pointee._rawHashValue(seed: seed)
},
hashGenerator: {
targetKeys[$0.offset]._rawHashValue_temp(seed: seed)
targetKeys[$0.offset]._rawHashValue(seed: seed)
},
swapper: {
swap(&srcKey.pointee, &targetKeys[$0.offset])
@@ -14,12 +14,23 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.2) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(<6.4) || !COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(*, unavailable, message: "RigidSet requires a Swift 6.4 toolchain")
@frozen
public struct RigidDictionary<
Key: Hashable,
Value: ~Copyable
>: ~Copyable {
package init() {
fatalError()
}
}
#else
@available(SwiftStdlib 5.0, *)
@frozen
@_addressableForDependencies
public struct RigidDictionary<
Key: GeneralizedHashable & ~Copyable,
Key: Hashable & ~Copyable,
Value: ~Copyable
>: ~Copyable {
@usableFromInline
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension RigidSet: BorrowingSequence where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -13,7 +13,7 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -15,7 +15,7 @@ import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet {
@@ -27,7 +27,7 @@ extension RigidSet {
}
@available(SwiftStdlib 5.0, *)
extension RigidSet: GeneralizedEquatable { // Should be Equatable
extension RigidSet: Equatable {
@inlinable
public static func ==(left: borrowing Self, right: borrowing Self) -> Bool {
if left.isTriviallyIdentical(to: right) { return true }
@@ -14,10 +14,10 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet: GeneralizedHashable { // Should be Hashable
extension RigidSet: Hashable {
@inlinable
public func hash(into hasher: inout Hasher) {
// Generate a seed from a snapshot of the hasher. This makes members' hash
@@ -36,7 +36,7 @@ extension RigidSet: GeneralizedHashable { // Should be Hashable
let next = it.nextSpan()
var i = 0
while i < next.count {
hash ^= next[i]._rawHashValue_temp(seed: seed)
hash ^= next[i]._rawHashValue(seed: seed)
i &+= 1
}
}
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -69,7 +69,7 @@ extension RigidSet where Element: ~Copyable {
let bucket = _table.insertNew_Large(
hashValue: hashValue,
hashGenerator: {
storage[$0]._rawHashValue_temp(seed: seed)
storage[$0]._rawHashValue(seed: seed)
},
swapper: {
swap(&item, &storage[$0])
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -49,7 +49,7 @@ extension RigidSet where Element: ~Copyable {
_table.resolveHole(
at: bucket,
hashGenerator: {
members[$0.offset]._rawHashValue_temp(seed: seed)
members[$0.offset]._rawHashValue(seed: seed)
},
mover: {
(members + $1.offset).initialize(to: (members + $0.offset).move())
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension RigidSet where Element: ~Copyable {
@@ -64,10 +64,10 @@ extension RigidSet where Element: ~Copyable {
from: &old._table,
selector: {
src = source + $0.offset
return src.pointee._rawHashValue_temp(seed: seed)
return src.pointee._rawHashValue(seed: seed)
},
hashGenerator: {
target[$0.offset]._rawHashValue_temp(seed: seed)
target[$0.offset]._rawHashValue(seed: seed)
},
swapper: {
swap(&src.pointee, &target[$0.offset])
@@ -15,12 +15,21 @@ import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(<6.4) || !COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
/// A fixed-capacity, noncopyable, unordered hashed container of unique
/// elements.
@available(*, unavailable, message: "RigidSet requires a Swift 6.4 toolchain")
public struct RigidSet<Element: Hashable>: ~Copyable {
package init() {
fatalError()
}
}
#else
/// A fixed-capacity, noncopyable, unordered hashed container of unique
/// elements.
@available(SwiftStdlib 5.0, *)
@frozen
public struct RigidSet<Element: GeneralizedHashable & ~Copyable>: ~Copyable {
public struct RigidSet<Element: Hashable & ~Copyable>: ~Copyable {
@usableFromInline
package typealias _Bucket = _HTable.Bucket
@@ -150,7 +159,7 @@ extension RigidSet where Element: ~Copyable {
internal borrowing func _hashValue(
for item: borrowing Element
) -> Int {
item._rawHashValue_temp(seed: _seed)
item._rawHashValue(seed: _seed)
}
}
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -15,7 +15,7 @@ import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary {
@@ -39,7 +39,7 @@ extension UniqueDictionary {
}
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary: GeneralizedEquatable where Value: GeneralizedEquatable { // Should be Equatable
extension UniqueDictionary: Equatable where Value: Equatable {
@inlinable
@inline(__always)
public static func ==(left: borrowing Self, right: borrowing Self) -> Bool {
@@ -14,10 +14,10 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary: GeneralizedHashable where Value: GeneralizedHashable { // Should be Hashable
extension UniqueDictionary: Hashable where Value: Hashable {
@inlinable
@inline(__always)
public func hash(into hasher: inout Hasher) {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@@ -9,13 +9,22 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(<6.4) || !COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(*, unavailable, message: "RigidSet requires a Swift 6.4 toolchain")
public struct UniqueDictionary<
Key: Hashable,
Value: ~Copyable
>: ~Copyable {
package init() {
fatalError()
}
}
#else
@available(SwiftStdlib 5.0, *)
@frozen
@_addressableForDependencies
public struct UniqueDictionary<
Key: GeneralizedHashable & ~Copyable,
Key: Hashable & ~Copyable,
Value: ~Copyable
>: ~Copyable {
@usableFromInline
@@ -14,7 +14,7 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension UniqueSet: BorrowingSequence where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -15,7 +15,7 @@ import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet {
@@ -27,7 +27,7 @@ extension UniqueSet {
}
@available(SwiftStdlib 5.0, *)
extension UniqueSet: GeneralizedEquatable { // Should be Equatable
extension UniqueSet: Equatable {
@inlinable
@inline(__always)
public static func ==(left: borrowing Self, right: borrowing Self) -> Bool {
@@ -14,10 +14,10 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet: GeneralizedHashable { // Should be Hashable
extension UniqueSet: Hashable {
@inlinable
public func hash(into hasher: inout Hasher) {
_storage.hash(into: &hasher)
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -13,7 +13,7 @@
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(SwiftStdlib 5.0, *)
extension UniqueSet where Element: ~Copyable {
@@ -14,11 +14,17 @@ import InternalCollectionsUtilities
import ContainersPreview
#endif
#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS
#if compiler(<6.4) || !COLLECTIONS_UNSTABLE_HASHED_CONTAINERS
@available(*, unavailable, message: "RigidSet requires a Swift 6.4 toolchain")
public struct UniqueSet<Element: Hashable>: ~Copyable {
package init() {
fatalError()
}
}
#else
@available(SwiftStdlib 5.0, *)
@frozen
public struct UniqueSet<Element: GeneralizedHashable & ~Copyable>: ~Copyable {
public struct UniqueSet<Element: Hashable & ~Copyable>: ~Copyable {
@usableFromInline
package typealias _Bucket = _HTable.Bucket