Drop support for Swift 6.0 and 6.1

This allows the use of Span types without `#if compiler` guards.
This commit is contained in:
Karoy Lorentey committed 2026-09-21 13:34:39 -07:00
1 parent 78bb4bf6b9
commit 537bf9cbfb
145 files changed
+342 -1047

No files matched your search

@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
@frozen
@@ -70,7 +69,7 @@ extension _HTable.Bitmap {
package func clearAll() {
_words.update(repeating: .empty)
}
@_alwaysEmitIntoClient
package func occupiedCount() -> Int {
var c = 0
@@ -197,4 +196,3 @@ extension _HTable.Bitmap {
return result
}
}
#endif
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
/// Identifies a particular bucket within a hash table by its offset.
/// Having a dedicated wrapper type for this prevents passing a bucket number
@@ -102,7 +101,7 @@ extension _HTable.Bucket {
package var word: Int {
Int(truncatingIfNeeded: offset &>> Word.wordShift)
}
@_alwaysEmitIntoClient
@_transparent
package var bit: UInt {
@@ -135,7 +134,7 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
return _ptr(at: bucket.offset)
}
}
@_alwaysEmitIntoClient
@_transparent
package func _ptr(
@@ -143,7 +142,7 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
) -> UnsafeMutablePointer<Element> {
_ptr(at: bucket.offset)
}
@_alwaysEmitIntoClient
@_transparent
package func _initializeElement(
@@ -152,7 +151,7 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
) {
initializeElement(at: bucket.offset, to: value)
}
@_alwaysEmitIntoClient
@_transparent
package func _extracting(_ buckets: Range<_HTable.Bucket>) -> Self {
@@ -171,5 +170,3 @@ extension Range where Bound == _HTable.Bucket {
}
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
package mutating func consumeAll(
@@ -25,5 +23,3 @@ extension _HTable {
clear()
}
}
#endif
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
package func maxOccupiedRun() -> Int {
if isSmall { return self.count }
@@ -61,7 +60,7 @@ extension _HTable {
}
return str
}
package func describe(
bitmap: Bool = false,
) -> String {
@@ -78,11 +77,11 @@ extension _HTable {
}
return s
}
package var description: String {
describe()
}
package func checkInvariants(
failureHandler: (String) -> Void,
hashGenerator: (Bucket) -> Int
@@ -104,13 +103,13 @@ extension _HTable {
}
return
}
// large
let c = bitmap.occupiedCount()
if c != self.count {
failureHandler("Count does not match bitmap count (count: \(self.count), bitmap: \(c))")
}
guard c > 0 else { return }
// Start iterating from the first empty bucket, wrapping around once
var it = self.makeBucketIterator()
@@ -167,4 +166,3 @@ extension _HTable {
#endif
}
}
#endif
@@ -13,7 +13,6 @@
#if COLLECTIONS_SINGLE_MODULE
#if compiler(>=6.2)
extension _HTable.BucketIterator {
// FIXME: Remove after 27.0 releases
@available(*, deprecated, renamed: "advanceToOccupied(maxCount:)")
@@ -58,6 +57,3 @@ extension _HTable.BucketIterator {
}
}
#endif
#endif
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
internal func find_Small(
@@ -63,4 +62,3 @@ extension _HTable {
#endif
}
}
#endif
@@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
internal mutating func insertNew_Small(
@@ -27,8 +26,8 @@ extension _HTable {
_maxProbeLength = _count
return r
}
@usableFromInline
internal mutating func insertNew_Large(
hashValue: Int,
@@ -37,7 +36,7 @@ extension _HTable {
) -> Bucket {
assert(!isSmall)
assert(!isFull)
#if COLLECTIONS_NO_ROBIN_HOOD_HASHING
let ideal = idealBucket(forHashValue: hashValue)
let bitmap = self.bitmap
@@ -84,4 +83,3 @@ extension _HTable {
#endif
}
}
#endif
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
@_lifetime(borrow self)
@@ -53,7 +52,7 @@ extension _HTable {
@_alwaysEmitIntoClient
package var _bucket: Bucket
/// Remaining bits not yet processed from the last word read.
@_alwaysEmitIntoClient
package var _nextBits: Word
@@ -98,13 +97,13 @@ extension _HTable.BucketIterator {
package var currentBucket: Bucket {
_bucket
}
@usableFromInline
@_transparent
package var isAtEnd: Bool {
_bucket >= _endBucket
}
@usableFromInline
@_transparent
package var isOccupied: Bool {
@@ -112,7 +111,7 @@ extension _HTable.BucketIterator {
if _words == nil { return true }
return _nextBits.contains(0)
}
@_transparent
@_lifetime(self: copy self)
package mutating func restart() {
@@ -123,7 +122,7 @@ extension _HTable.BucketIterator {
_nextBitCount = UInt8(Swift.min(Word._capacity, _endBucket._offset))
}
}
@_transparent
@_lifetime(self: copy self)
package mutating func _wrap() {
@@ -266,7 +265,7 @@ extension _HTable.BucketIterator {
}
return true
}
@usableFromInline
@_lifetime(self: copy self)
package mutating func wrapToOccupied() {
@@ -392,4 +391,3 @@ extension _HTable.BucketIterator {
return Range(uncheckedBounds: (start, end))
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
extension _HTable {
/// Create a hole at the specified occupied bucket without marking it as
/// unoccupied or restoring the hash table's other invariants. After a hole
@@ -25,7 +23,7 @@ extension _HTable {
assert(isOccupied(bucket))
_count &-= 1
}
/// Restore hash table invariants after a hole was created by `createHole`.
/// This works by swapping items as needed to move the hole forward until we
/// reach the end of the affected chain of occupied buckets.
@@ -120,5 +118,3 @@ extension _HTable {
return bucket
}
}
#endif
@@ -11,8 +11,6 @@
//
//===----------------------------------------------------------------------===//
#if compiler(>=6.2)
extension _HTable {
@usableFromInline
package mutating func migrateItems_Small(
@@ -23,7 +21,7 @@ extension _HTable {
assert(self.isSmall)
assert(source.count <= self.capacity)
guard !source.isEmpty else { return }
// Let's reverse the order of members, to emphasize that this is not an
// ordered container.
let c = source.count
@@ -41,7 +39,7 @@ extension _HTable {
}
source.clear()
}
@usableFromInline
package mutating func migrateItems_Large(
from source: inout _HTable,
@@ -54,7 +52,7 @@ extension _HTable {
assert(!self.isSmall)
assert(source.count <= self.capacity)
guard !source.isEmpty else { return }
// Move & rehash items one by one.
var it = source.makeBucketIterator()
while let next = it.nextOccupiedRegion() {
@@ -72,5 +70,3 @@ extension _HTable {
source.clear()
}
}
#endif
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
extension _HTable {
/// The minimum hash table scale.
@_alwaysEmitIntoClient
@@ -26,7 +25,7 @@ extension _HTable {
4
}
}
/// The maximum hash table scale.
@_alwaysEmitIntoClient
package static var maximumScale: UInt8 {
@@ -36,7 +35,7 @@ extension _HTable {
Swift.min(UInt8(truncatingIfNeeded: Int.bitWidth) &- 1, 56)
}
}
/// The maximum number of items for which we do not create a hash table.
@usableFromInline
package static var maximumUnhashedCount: Int {
@@ -45,7 +44,7 @@ extension _HTable {
maximumCapacity(forScale: 0)
}
}
@inlinable
@inline(__always)
package static func wordCount(forScale scale: UInt8) -> Int {
@@ -72,24 +71,24 @@ extension _HTable {
// away. This provides hysteresis for storage capacities, preventing hash
// tables from repeatedly shrinking/growing when only a handful of items are
// added/removed in a loop.
/// The numerator of the maximum hash table load factor.
@_transparent
internal static var _maxLFNum: UInt { 7 }
/// The denominator of the maximum hash table load factor.
@_transparent
internal static var _maxLFDenom: UInt { 8 }
/// The numerator of the minimum hash table load factor.
@_transparent
internal static var _minLFNum: UInt { 1 }
/// The denominator of minimum hash table load factor.
@_alwaysEmitIntoClient
@_transparent
internal static var _minLFDenom: UInt { 8 }
/// The minimum number of items that can be held in a hash table of the given scale.
@usableFromInline
@_effects(readnone)
@@ -99,7 +98,7 @@ extension _HTable {
let bucketCount: UInt = 1 &<< scale
return Int(bucketCount * _minLFNum / _minLFDenom)
}
/// The maximum number of items that can be held in a hash table of the given scale.
@usableFromInline
@_effects(readnone)
@@ -108,8 +107,8 @@ extension _HTable {
let bucketCount: UInt = 1 &<< scale
return Int(bucketCount * _maxLFNum / _maxLFDenom)
}
/// The minimum hash table scale that can hold the specified number of elements.
@usableFromInline
@_effects(readnone)
@@ -151,4 +150,3 @@ extension _HTable {
return (scale, capacity)
}
}
#endif
+10 -12
View File
@@ -15,7 +15,6 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2)
@usableFromInline
@frozen
package struct _HTable: ~Copyable {
@@ -30,13 +29,13 @@ package struct _HTable: ~Copyable {
@_alwaysEmitIntoClient
package let _bitmap: UnsafeMutablePointer<Word>?
@_alwaysEmitIntoClient
package var _maxProbeLength: Int
@_alwaysEmitIntoClient
package let scale: UInt8
// FIXME: Add a reservedScale for UniqueSet/UniqueDictonary
@inlinable
@@ -61,7 +60,7 @@ package struct _HTable: ~Copyable {
self._bitmap = bitmap
}
}
@inlinable
internal init(capacity: Int) {
assert(capacity >= 0)
@@ -69,7 +68,7 @@ package struct _HTable: ~Copyable {
_capacity: capacity,
scale: Self.minimumScale(forCapacity: capacity))
}
@inlinable
internal init(minimumCapacity: Int) {
precondition(minimumCapacity >= 0, "Capacity must be nonnegative")
@@ -77,7 +76,7 @@ package struct _HTable: ~Copyable {
self.init(_capacity: p.capacity, scale: p.scale)
}
@_alwaysEmitIntoClient
deinit {
_bitmap?.deallocate()
@@ -115,7 +114,7 @@ extension _HTable {
_count == capacity
}
@_alwaysEmitIntoClient
@_transparent
package var wordCount: Int {
@@ -130,7 +129,7 @@ extension _HTable {
package var startBucket: Bucket {
Bucket(offset: 0)
}
@_alwaysEmitIntoClient
@_transparent
package var endBucket: Bucket {
@@ -149,13 +148,13 @@ extension _HTable {
package var bucketCount: UInt {
UInt(bitPattern: storageCapacity)
}
@_transparent
@inlinable
package func isValid(_ bucket: Bucket) -> Bool {
bucket._offset < bucketCount
}
@_transparent
@inlinable
package func wrapBucket(after bucket: inout Bucket) {
@@ -180,7 +179,7 @@ extension _HTable {
Bitmap(table: self)
}
}
@_transparent
@inlinable
package func isOccupied(_ bucket: Bucket) -> Bool {
@@ -236,4 +235,3 @@ extension _HTable {
&& self.scale == other.scale
}
}
#endif