diff --git a/Package.swift b/Package.swift index cbdd3043..f90d64cd 100644 --- a/Package.swift +++ b/Package.swift @@ -35,7 +35,7 @@ let _traits: Set = [ types before they ship. """), .trait( - name: "UnstableNoncopyableKeys", + name: "UnstableHashedContainers", description: """ Enables support for noncopyable set members and dictionary keys in `BasicContainers`. This requires a Standard Library with generalized @@ -57,8 +57,8 @@ var defines: [SwiftSetting] = [ "COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS", .when(traits: ["UnstableSortedCollections"])), .define( - "COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS", - .when(traits: ["UnstableNoncopyableKeys"])), + "COLLECTIONS_UNSTABLE_HASHED_CONTAINERS", + .when(traits: ["UnstableHashedContainers"])), // Enables internal consistency checks at the end of initializers and // mutating operations. This can have very significant overhead, so enabling @@ -113,8 +113,8 @@ let availabilityMacros: KeyValuePairs = [ ] let extraSettings: [SwiftSetting] = [ + // .strictMemorySafety(), .enableUpcomingFeature("MemberImportVisibility"), -// .strictMemorySafety(), .enableExperimentalFeature("BuiltinModule"), .enableExperimentalFeature("Lifetimes"), .enableExperimentalFeature("InoutLifetimeDependence"), diff --git a/Sources/BasicContainers/CMakeLists.txt b/Sources/BasicContainers/CMakeLists.txt index ade9bfd9..a0041da0 100644 --- a/Sources/BasicContainers/CMakeLists.txt +++ b/Sources/BasicContainers/CMakeLists.txt @@ -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" diff --git a/Sources/BasicContainers/HashTable/ProtocolGeneralizations.swift b/Sources/BasicContainers/HashTable/ProtocolGeneralizations.swift deleted file mode 100644 index a7c818ee..00000000 --- a/Sources/BasicContainers/HashTable/ProtocolGeneralizations.swift +++ /dev/null @@ -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 diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Consumption.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Consumption.swift index 49acabdf..c65093f8 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Consumption.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Consumption.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Equatable.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Equatable.swift index 80feb3ca..729b62c4 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Equatable.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Equatable.swift @@ -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: ==) diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Hashable.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Hashable.swift index 7fc8cf68..c51d00cb 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Hashable.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Hashable.swift @@ -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 diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Index.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Index.swift index 2b322592..0931e36a 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Index.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Index.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift index ce28e2f2..fe86158f 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Indices.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Initializers.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Initializers.swift index 343681f3..f9a3664d 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Initializers.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Initializers.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Insertions.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Insertions.swift index 0df9d603..536123f0 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Insertions.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Insertions.swift @@ -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]) diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Keys.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Keys.swift index 437d8c48..0bc2b3a3 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Keys.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Keys.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Lookup.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Lookup.swift index 2bd11e50..2ca5247f 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Lookup.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Lookup.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Removals.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Removals.swift index e469e470..ac4e48f5 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Removals.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Removals.swift @@ -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()) diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Resizing.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Resizing.swift index 52e3a3ac..384f4c0f 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary+Resizing.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary+Resizing.swift @@ -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]) diff --git a/Sources/BasicContainers/RigidDictionary/RigidDictionary.swift b/Sources/BasicContainers/RigidDictionary/RigidDictionary.swift index a06ffff2..c9146ccb 100644 --- a/Sources/BasicContainers/RigidDictionary/RigidDictionary.swift +++ b/Sources/BasicContainers/RigidDictionary/RigidDictionary.swift @@ -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 diff --git a/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift b/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift index 8efb1ba4..07bcefc8 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+BorrowingSequence.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Consumption.swift b/Sources/BasicContainers/RigidSet/RigidSet+Consumption.swift index d596bb03..baf2e82c 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Consumption.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Consumption.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Debugging.swift b/Sources/BasicContainers/RigidSet/RigidSet+Debugging.swift index 74af7d3f..9e2b1c43 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Debugging.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Debugging.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift b/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift index 7dca176e..c55cbe9b 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Equatable.swift @@ -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 } diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift b/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift index e2119b54..92746f41 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Hashable.swift @@ -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 } } diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Index.swift b/Sources/BasicContainers/RigidSet/RigidSet+Index.swift index f7a41949..cc626b42 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Index.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Index.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift b/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift index 7a682a02..2fdf5a8d 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Initializers.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift b/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift index 094f2517..8ae13a7b 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Insertions.swift @@ -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]) diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Lookup.swift b/Sources/BasicContainers/RigidSet/RigidSet+Lookup.swift index 043e93fa..b4231970 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Lookup.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Lookup.swift @@ -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 { diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Removals.swift b/Sources/BasicContainers/RigidSet/RigidSet+Removals.swift index 8ef78175..64e6423d 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Removals.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Removals.swift @@ -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()) diff --git a/Sources/BasicContainers/RigidSet/RigidSet+Resizing.swift b/Sources/BasicContainers/RigidSet/RigidSet+Resizing.swift index 57ab7c35..2d339c16 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet+Resizing.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet+Resizing.swift @@ -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]) diff --git a/Sources/BasicContainers/RigidSet/RigidSet.swift b/Sources/BasicContainers/RigidSet/RigidSet.swift index 1236f649..a10f390a 100644 --- a/Sources/BasicContainers/RigidSet/RigidSet.swift +++ b/Sources/BasicContainers/RigidSet/RigidSet.swift @@ -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: ~Copyable { + package init() { + fatalError() + } +} +#else /// A fixed-capacity, noncopyable, unordered hashed container of unique /// elements. @available(SwiftStdlib 5.0, *) @frozen -public struct RigidSet: ~Copyable { +public struct RigidSet: ~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) } } diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Consumption.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Consumption.swift index 8bf3f236..aeff0fec 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Consumption.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Consumption.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Equatable.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Equatable.swift index eeb82643..6474f35a 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Equatable.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Equatable.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Hashable.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Hashable.swift index ff98b4b4..0375b084 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Hashable.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Hashable.swift @@ -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) { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Index.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Index.swift index 3c2550ce..0d360c35 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Index.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Index.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Indices.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Indices.swift index e0522775..b9e35ac7 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Indices.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Indices.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Initializers.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Initializers.swift index f44cfedc..9237280f 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Initializers.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Initializers.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Insertions.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Insertions.swift index e1817522..6cf169f5 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Insertions.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Insertions.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Keys.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Keys.swift index b95260ea..35539c77 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Keys.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Keys.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Lookup.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Lookup.swift index 8e8e3aaa..67d9556c 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Lookup.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Lookup.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Removals.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Removals.swift index 715ce884..30804e10 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Removals.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Removals.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Resizing.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Resizing.swift index dd828d8c..1d582569 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Resizing.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary+Resizing.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary.swift b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary.swift index 45d51114..9695c50c 100644 --- a/Sources/BasicContainers/UniqueDictionary/UniqueDictionary.swift +++ b/Sources/BasicContainers/UniqueDictionary/UniqueDictionary.swift @@ -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 diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift index 44ae4d8b..fec0f9d5 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+BorrowingSequence.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Consumption.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Consumption.swift index ec6528a6..613a2657 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Consumption.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Consumption.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Debugging.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Debugging.swift index fd7818d6..e68dbc63 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Debugging.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Debugging.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Equatable.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Equatable.swift index ba8bc592..a41f0ac8 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Equatable.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Equatable.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Hashable.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Hashable.swift index f30389f3..56167490 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Hashable.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Hashable.swift @@ -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) diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Index.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Index.swift index e31b8acc..69fbc4ce 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Index.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Index.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift index db85ba6b..1b8f017f 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Initializers.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift index 78b0bf9c..5d14e66d 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Insertions.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Lookup.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Lookup.swift index 57df5c58..7ee3430b 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Lookup.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Lookup.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Removals.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Removals.swift index a8af1c96..5ee47df9 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Removals.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Removals.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet+Resizing.swift b/Sources/BasicContainers/UniqueSet/UniqueSet+Resizing.swift index 0bf3c2b7..61b238f6 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet+Resizing.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet+Resizing.swift @@ -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 { diff --git a/Sources/BasicContainers/UniqueSet/UniqueSet.swift b/Sources/BasicContainers/UniqueSet/UniqueSet.swift index 99603967..3cec80bc 100644 --- a/Sources/BasicContainers/UniqueSet/UniqueSet.swift +++ b/Sources/BasicContainers/UniqueSet/UniqueSet.swift @@ -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: ~Copyable { + package init() { + fatalError() + } +} +#else @available(SwiftStdlib 5.0, *) @frozen -public struct UniqueSet: ~Copyable { +public struct UniqueSet: ~Copyable { @usableFromInline package typealias _Bucket = _HTable.Bucket diff --git a/Tests/BasicContainersTests/RigidDictionaryTests.swift b/Tests/BasicContainersTests/RigidDictionaryTests.swift index 6de7905f..efc9b4ef 100644 --- a/Tests/BasicContainersTests/RigidDictionaryTests.swift +++ b/Tests/BasicContainersTests/RigidDictionaryTests.swift @@ -18,7 +18,7 @@ import BasicContainers import ContainersPreview #endif -#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS +#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS class RigidDictionaryTests: CollectionTestCase { func test_empty() { diff --git a/Tests/BasicContainersTests/RigidSetTests.swift b/Tests/BasicContainersTests/RigidSetTests.swift index da814ae3..579720ae 100644 --- a/Tests/BasicContainersTests/RigidSetTests.swift +++ b/Tests/BasicContainersTests/RigidSetTests.swift @@ -17,7 +17,7 @@ import _CollectionsTestSupport import BasicContainers #endif -#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS +#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS class RigidSetTests: CollectionTestCase { func test_empty() { diff --git a/Tests/BasicContainersTests/UniqueDictionaryTests.swift b/Tests/BasicContainersTests/UniqueDictionaryTests.swift index cb2e9652..ad046492 100644 --- a/Tests/BasicContainersTests/UniqueDictionaryTests.swift +++ b/Tests/BasicContainersTests/UniqueDictionaryTests.swift @@ -18,7 +18,7 @@ import BasicContainers import ContainersPreview #endif -#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS +#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS class UniqueDictionaryTests: CollectionTestCase { func test_empty() { diff --git a/Tests/BasicContainersTests/UniqueSetTests.swift b/Tests/BasicContainersTests/UniqueSetTests.swift index ee6fa397..3f965ce7 100644 --- a/Tests/BasicContainersTests/UniqueSetTests.swift +++ b/Tests/BasicContainersTests/UniqueSetTests.swift @@ -17,7 +17,7 @@ import _CollectionsTestSupport import BasicContainers #endif -#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS +#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS class UniqueSetTests: CollectionTestCase { func test_empty() { let s = UniqueSet() diff --git a/Tests/_CollectionsTestSupport/Utilities/LifetimeTracked.swift b/Tests/_CollectionsTestSupport/Utilities/LifetimeTracked.swift index 1cb908b7..959ef198 100644 --- a/Tests/_CollectionsTestSupport/Utilities/LifetimeTracked.swift +++ b/Tests/_CollectionsTestSupport/Utilities/LifetimeTracked.swift @@ -78,11 +78,6 @@ extension LifetimeTracked: Hashable where Payload: Hashable { } } -#if compiler(>=6.3) && COLLECTIONS_UNSTABLE_NONCOPYABLE_KEYS -extension LifetimeTracked: GeneralizedEquatable where Payload: Equatable {} -extension LifetimeTracked: GeneralizedHashable where Payload: Hashable {} -#endif - extension LifetimeTracked: Comparable where Payload: Comparable { public static func < (left: LifetimeTracked, right: LifetimeTracked) -> Bool { return left.payload < right.payload diff --git a/Tests/_CollectionsTestSupport/Utilities/LifetimeTrackedStruct.swift b/Tests/_CollectionsTestSupport/Utilities/LifetimeTrackedStruct.swift index 6c961f98..3844d24c 100644 --- a/Tests/_CollectionsTestSupport/Utilities/LifetimeTrackedStruct.swift +++ b/Tests/_CollectionsTestSupport/Utilities/LifetimeTrackedStruct.swift @@ -68,6 +68,27 @@ extension LifetimeTrackedStruct: TestPrintable where Payload: TestPrintable & ~C } #endif +#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_HASHED_CONTAINERS +extension LifetimeTrackedStruct: Equatable where Payload: Equatable & ~Copyable { + public static func == (left: borrowing Self, right: borrowing Self) -> Bool { + return left.payload == right.payload + } +} + +extension LifetimeTrackedStruct: Hashable where Payload: Hashable & ~Copyable { + public func _rawHashValue(seed: Int) -> Int { + payload._rawHashValue(seed: seed) + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(payload) + } + + public var hashValue: Int { + payload.hashValue + } +} +#else extension LifetimeTrackedStruct/*: Equatable*/ where Payload: Equatable /*& ~Copyable*/ { public static func == (left: borrowing Self, right: borrowing Self) -> Bool { return left.payload == right.payload @@ -87,6 +108,7 @@ extension LifetimeTrackedStruct/*: Hashable*/ where Payload: Hashable /*& ~Copya payload.hashValue } } +#endif extension LifetimeTrackedStruct/*: Comparable*/ where Payload: Comparable /*& ~Copyable*/ { public static func < (left: borrowing Self, right: borrowing Self) -> Bool { diff --git a/Xcode/Collections.xcodeproj/project.pbxproj b/Xcode/Collections.xcodeproj/project.pbxproj index 44bd46bb..fddee785 100644 --- a/Xcode/Collections.xcodeproj/project.pbxproj +++ b/Xcode/Collections.xcodeproj/project.pbxproj @@ -65,7 +65,6 @@ 7D2A779C2F27F2BF005780C7 /* Deque+ExpressibleByArrayLiteral.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A775C2F27F2BF005780C7 /* Deque+ExpressibleByArrayLiteral.swift */; }; 7D2A779F2F27F367005780C7 /* InoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A779E2F27F367005780C7 /* InoutTests.swift */; }; 7D2A77A02F27F367005780C7 /* BorrowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A779D2F27F367005780C7 /* BorrowTests.swift */; }; - 7D3D2DC92F3E5D110055E70B /* ProtocolGeneralizations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3D2DC82F3E5D0E0055E70B /* ProtocolGeneralizations.swift */; }; 7D479CB02F450E4600A8CB59 /* RigidSet+BorrowingSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D479CAF2F450E3F00A8CB59 /* RigidSet+BorrowingSequence.swift */; }; 7D479CB32F45296A00A8CB59 /* UniqueSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D479CB12F45296000A8CB59 /* UniqueSet.swift */; }; 7D479CB52F452D6900A8CB59 /* UniqueSetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D479CB42F452D6700A8CB59 /* UniqueSetTests.swift */; }; @@ -632,7 +631,6 @@ 7D2A77762F27F2BF005780C7 /* UniqueDeque+Replacements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueDeque+Replacements.swift"; sourceTree = ""; }; 7D2A779D2F27F367005780C7 /* BorrowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BorrowTests.swift; sourceTree = ""; }; 7D2A779E2F27F367005780C7 /* InoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InoutTests.swift; sourceTree = ""; }; - 7D3D2DC82F3E5D0E0055E70B /* ProtocolGeneralizations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProtocolGeneralizations.swift; sourceTree = ""; }; 7D479CAF2F450E3F00A8CB59 /* RigidSet+BorrowingSequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RigidSet+BorrowingSequence.swift"; sourceTree = ""; }; 7D479CB12F45296000A8CB59 /* UniqueSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniqueSet.swift; sourceTree = ""; }; 7D479CB42F452D6700A8CB59 /* UniqueSetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniqueSetTests.swift; sourceTree = ""; }; @@ -1363,7 +1361,6 @@ 7D479CF22F47FB3D00A8CB59 /* _HTable+Removal.swift */, 7D479CE82F47DE1C00A8CB59 /* _HTable+Resizing.swift */, 7D72467D2F3D9DDB00112FD0 /* _HTable+Sizing.swift */, - 7D3D2DC82F3E5D0E0055E70B /* ProtocolGeneralizations.swift */, ); path = HashTable; sourceTree = ""; @@ -2502,7 +2499,6 @@ 7D2A778C2F27F2BF005780C7 /* UniqueDeque+Prepend.swift in Sources */, 7D2A778D2F27F2BF005780C7 /* UniqueDeque.swift in Sources */, 7D2A778E2F27F2BF005780C7 /* RigidDeque.swift in Sources */, - 7D3D2DC92F3E5D110055E70B /* ProtocolGeneralizations.swift in Sources */, 7D2A778F2F27F2BF005780C7 /* Deque+CustomReflectable.swift in Sources */, 7D2A77902F27F2BF005780C7 /* RigidDeque+Insertions.swift in Sources */, 7D2A77912F27F2BF005780C7 /* RigidDeque+Removals.swift in Sources */,