diff --git a/Sources/DequeModule/Deque+Collection.swift b/Sources/DequeModule/Deque+Collection.swift index 8bf44b8f..adb896a8 100644 --- a/Sources/DequeModule/Deque+Collection.swift +++ b/Sources/DequeModule/Deque+Collection.swift @@ -13,6 +13,8 @@ import InternalCollectionsUtilities #endif +import Future + extension Deque { // Implementation note: we could also use the default `IndexingIterator` here. // This custom implementation performs direct storage access to eliminate any diff --git a/Sources/DequeModule/Deque+Equatable.swift b/Sources/DequeModule/Deque+Equatable.swift index 45d49c37..eb0f4709 100644 --- a/Sources/DequeModule/Deque+Equatable.swift +++ b/Sources/DequeModule/Deque+Equatable.swift @@ -9,6 +9,8 @@ // //===----------------------------------------------------------------------===// +import Future + extension Deque: Equatable where Element: Equatable { /// Returns a Boolean value indicating whether two values are equal. Two /// deques are considered equal if they contain the same elements in the same diff --git a/Sources/DequeModule/Deque.swift b/Sources/DequeModule/Deque.swift index 33b2cadc..034bb806 100644 --- a/Sources/DequeModule/Deque.swift +++ b/Sources/DequeModule/Deque.swift @@ -9,6 +9,8 @@ // //===----------------------------------------------------------------------===// +import Future + /// A collection implementing a double-ended queue. `Deque` (pronounced "deck") /// implements an ordered random-access collection that supports efficient /// insertions and removals from both ends. diff --git a/Sources/DequeModule/RigidDeque.swift b/Sources/DequeModule/RigidDeque.swift index 35b39f1e..118a4290 100644 --- a/Sources/DequeModule/RigidDeque.swift +++ b/Sources/DequeModule/RigidDeque.swift @@ -95,16 +95,16 @@ public struct _DequeBorrowingIterator: BorrowingIteratorProt let d = Swift.min(maximumCount, _segments.first.count - _offset) let slice = _segments.first.extracting(_offset ..< _offset + d) _offset += d - return Span(unsafeElements: slice, owner: self) + return Span(_unsafeElements: slice) } guard let second = _segments.second else { - return Span(unsafeElements: UnsafeBufferPointer._empty, owner: self) + return Span(_unsafeElements: UnsafeBufferPointer._empty) } let o = _offset - _segments.first.count let d = Swift.min(maximumCount, second.count - o) let slice = second.extracting(o ..< o + d) _offset += d - return Span(unsafeElements: slice, owner: self) + return Span(_unsafeElements: slice) } } diff --git a/Sources/Future/Containers/NewArray.swift b/Sources/Future/Containers/NewArray.swift index 8c9b0111..423fb565 100644 --- a/Sources/Future/Containers/NewArray.swift +++ b/Sources/Future/Containers/NewArray.swift @@ -27,7 +27,7 @@ extension NewArray { // FIXME: This is what I want to write; alas, lifetimes are messed up. return _storage.value.storage #else - return Span(unsafeElements: _storage.value._items, owner: self) + return Span(_unsafeElements: _storage.value._items) #endif } } @@ -108,7 +108,7 @@ extension NewArray: RangeReplaceableCollection { self._storage = Shared(RigidArray(capacity: 0)) } - public func replaceSubrange( + mutating public func replaceSubrange( _ subrange: Range, with newElements: some Collection ) { diff --git a/Sources/Future/Containers/RigidArray.swift b/Sources/Future/Containers/RigidArray.swift index 5d190222..86c049d8 100644 --- a/Sources/Future/Containers/RigidArray.swift +++ b/Sources/Future/Containers/RigidArray.swift @@ -60,7 +60,7 @@ extension RigidArray where Element: ~Copyable { extension RigidArray where Element: ~Copyable { public var storage: Span { - Span(unsafeElements: _items, owner: self) + Span(_unsafeElements: _items) } } @@ -84,7 +84,7 @@ extension RigidArray: RandomAccessContainer where Element: ~Copyable { let end = _offset + Swift.min(maximumCount, _items.count - _offset) defer { _offset = end } let chunk = _items.extracting(Range(uncheckedBounds: (_offset, end))) - return Span(unsafeElements: chunk, owner: self) + return Span(_unsafeElements: chunk) } } @@ -242,7 +242,8 @@ extension RigidArray { internal func _copy(capacity: Int) -> Self { precondition(capacity >= count) var result = RigidArray(capacity: capacity) - result._storage.initializeAll(fromContentsOf: _storage) + let initialized = result._storage.initialize(fromContentsOf: _storage) + precondition(initialized == count) result._count = count return result } @@ -251,7 +252,8 @@ extension RigidArray { internal mutating func _move(capacity: Int) -> Self { precondition(capacity >= count) var result = RigidArray(capacity: capacity) - result._storage.moveInitializeAll(fromContentsOf: _storage) + let initialized = result._storage.moveInitialize(fromContentsOf: _storage) + precondition(initialized == count) result._count = count self._count = 0 return result diff --git a/Tests/OrderedCollectionsTests/OrderedSet/OrderedSet Diffing Tests.swift b/Tests/OrderedCollectionsTests/OrderedSet/OrderedSet Diffing Tests.swift index b5ea03f2..9d012a8f 100644 --- a/Tests/OrderedCollectionsTests/OrderedSet/OrderedSet Diffing Tests.swift +++ b/Tests/OrderedCollectionsTests/OrderedSet/OrderedSet Diffing Tests.swift @@ -18,13 +18,13 @@ import _CollectionsTestSupport #endif class MeasuringHashable: Hashable { - static var equalityChecks = 0 + nonisolated(unsafe) static var equalityChecks = 0 static func == (lhs: MeasuringHashable, rhs: MeasuringHashable) -> Bool { MeasuringHashable.equalityChecks += 1 return lhs._inner == rhs._inner } - static var hashChecks = 0 + nonisolated(unsafe) static var hashChecks = 0 func hash(into hasher: inout Hasher) { MeasuringHashable.hashChecks += 1 _inner.hash(into: &hasher) diff --git a/Tests/_CollectionsTestSupport/AssertionContexts/TestContext.swift b/Tests/_CollectionsTestSupport/AssertionContexts/TestContext.swift index ad3b89af..59816e67 100644 --- a/Tests/_CollectionsTestSupport/AssertionContexts/TestContext.swift +++ b/Tests/_CollectionsTestSupport/AssertionContexts/TestContext.swift @@ -20,7 +20,7 @@ public final class TestContext { internal var _trace: [Entry] = [] // FIXME: This ought to be a thread-local variable. - internal static var _current: TestContext? + nonisolated(unsafe) internal static var _current: TestContext? public init() {} }