Skip to content

[Concurrency] Remove redundant Sendable conformances in the standard library. #75495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions stdlib/public/core/ContiguousArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ internal final class __EmptyArrayStorage
}
}

@available(*, unavailable)
extension __EmptyArrayStorage: Sendable {}

#if $Embedded
// In embedded Swift, the stdlib is a .swiftmodule only without any .o/.a files,
// to allow consuming it by clients with different LLVM codegen setting (-mcpu
Expand Down Expand Up @@ -120,9 +117,6 @@ internal final class __StaticArrayStorage
}
}

@available(*, unavailable)
extension __StaticArrayStorage: Sendable {}

/// The empty array prototype. We use the same object for all empty
/// `[Native]Array<Element>`s.
@inlinable
Expand Down Expand Up @@ -312,9 +306,6 @@ internal final class _ContiguousArrayStorage<
}
}

@available(*, unavailable)
extension _ContiguousArrayStorage: Sendable {}

@_alwaysEmitIntoClient
@inline(__always)
internal func _uncheckedUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
Expand Down Expand Up @@ -977,9 +968,6 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
}
}

@available(*, unavailable)
extension _ContiguousArrayBuffer: Sendable {}

/// Append the elements of `rhs` to `lhs`.
@inlinable
internal func += <Element, C: Collection>(
Expand Down
3 changes: 0 additions & 3 deletions stdlib/public/core/DictionaryBridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ final internal class _SwiftDeferredNSDictionary<Key: Hashable, Value>
}
}

@available(*, unavailable)
extension _SwiftDeferredNSDictionary: Sendable {}

// NOTE: older runtimes called this struct _CocoaDictionary. The two
// must coexist without conflicting ObjC class names from the nested
// classes, so it was renamed. The old names must not be used in the new
Expand Down
9 changes: 0 additions & 9 deletions stdlib/public/core/DictionaryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ internal class __RawDictionaryStorage: __SwiftNativeNSDictionary {
}
}

@available(*, unavailable)
extension __RawDictionaryStorage: Sendable {}

/// The storage class for the singleton empty set.
/// The single instance of this class is created by the runtime.
// NOTE: older runtimes called this class _EmptyDictionarySingleton.
Expand All @@ -139,9 +136,6 @@ internal class __EmptyDictionarySingleton: __RawDictionaryStorage {
#endif
}

@available(*, unavailable)
extension __EmptyDictionarySingleton: Sendable {}

#if _runtime(_ObjC)
extension __EmptyDictionarySingleton: _NSDictionaryCore {
@objc(copyWithZone:)
Expand Down Expand Up @@ -511,6 +505,3 @@ extension _DictionaryStorage {
return storage
}
}

extension _DictionaryStorage: @unchecked Sendable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this unchecked Sendable conformance was incorrect, and _DictionaryStorage inherits an unavailable Sendable conformance from __RawDictionaryStorage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're right about this. Should be fine to remove 👍

where Key: Sendable, Value: Sendable {}
24 changes: 0 additions & 24 deletions stdlib/public/core/ExistentialCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ internal final class _IteratorBox<Base: IteratorProtocol>
internal var _base: Base
}

@available(*, unavailable)
extension _IteratorBox: Sendable {}

//===--- Sequence ---------------------------------------------------------===//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -402,9 +399,6 @@ internal class _AnyCollectionBox<Element>: _AnySequenceBox<Element> {
) -> _AnyCollectionBox<Element> { _abstract() }
}

@available(*, unavailable)
extension _AnyCollectionBox: Sendable {}

@_fixed_layout
@usableFromInline
internal class _AnyBidirectionalCollectionBox<Element>
Expand Down Expand Up @@ -468,9 +462,6 @@ internal class _AnyBidirectionalCollectionBox<Element>
internal func _formIndex(before i: _AnyIndexBox) { _abstract() }
}

@available(*, unavailable)
extension _AnyBidirectionalCollectionBox: Sendable {}

@_fixed_layout
@usableFromInline
internal class _AnyRandomAccessCollectionBox<Element>
Expand Down Expand Up @@ -528,9 +519,6 @@ internal class _AnyRandomAccessCollectionBox<Element>
) -> _AnyRandomAccessCollectionBox<Element> { _abstract() }
}

@available(*, unavailable)
extension _AnyRandomAccessCollectionBox: Sendable {}

@_fixed_layout
@usableFromInline
internal final class _SequenceBox<S: Sequence>: _AnySequenceBox<S.Element> {
Expand Down Expand Up @@ -623,9 +611,6 @@ internal final class _SequenceBox<S: Sequence>: _AnySequenceBox<S.Element> {
internal var _base: S
}

@available(*, unavailable)
extension _SequenceBox: Sendable {}

@_fixed_layout
@usableFromInline
internal final class _CollectionBox<S: Collection>: _AnyCollectionBox<S.Element>
Expand Down Expand Up @@ -820,9 +805,6 @@ internal final class _CollectionBox<S: Collection>: _AnyCollectionBox<S.Element>
internal var _base: S
}

@available(*, unavailable)
extension _CollectionBox: Sendable {}

@_fixed_layout
@usableFromInline
internal final class _BidirectionalCollectionBox<S: BidirectionalCollection>
Expand Down Expand Up @@ -1036,9 +1018,6 @@ internal final class _BidirectionalCollectionBox<S: BidirectionalCollection>
internal var _base: S
}

@available(*, unavailable)
extension _BidirectionalCollectionBox: Sendable {}

@_fixed_layout
@usableFromInline
internal final class _RandomAccessCollectionBox<S: RandomAccessCollection>
Expand Down Expand Up @@ -1251,9 +1230,6 @@ internal final class _RandomAccessCollectionBox<S: RandomAccessCollection>
internal var _base: S
}

@available(*, unavailable)
extension _RandomAccessCollectionBox: Sendable {}

@usableFromInline
@frozen
internal struct _ClosureBasedSequence<Iterator: IteratorProtocol> {
Expand Down
9 changes: 0 additions & 9 deletions stdlib/public/core/SetStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ internal class __RawSetStorage: __SwiftNativeNSSet {
}
}

@available(*, unavailable)
extension __RawSetStorage: Sendable {}

/// The storage class for the singleton empty set.
/// The single instance of this class is created by the runtime.
// NOTE: older runtimes called this class _EmptySetSingleton. The two
Expand All @@ -130,9 +127,6 @@ internal class __EmptySetSingleton: __RawSetStorage {
#endif
}

@available(*, unavailable)
extension __EmptySetSingleton: Sendable {}

#if $Embedded
// In embedded Swift, the stdlib is a .swiftmodule only without any .o/.a files,
// to allow consuming it by clients with different LLVM codegen setting (-mcpu
Expand Down Expand Up @@ -316,9 +310,6 @@ final internal class _SetStorage<Element: Hashable>
#endif
}

@available(*, unavailable)
extension _SetStorage: Sendable {}

extension _SetStorage {
@usableFromInline
@_effects(releasenone)
Expand Down
12 changes: 0 additions & 12 deletions stdlib/public/core/SwiftNativeNSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ internal class __SwiftNativeNSArrayWithContiguousStorage
}
}

@available(*, unavailable)
extension __SwiftNativeNSArrayWithContiguousStorage: Sendable {}

private let NSNotFound: Int = .max

// Implement the APIs required by NSArray
Expand Down Expand Up @@ -325,9 +322,6 @@ extension __SwiftNativeNSArrayWithContiguousStorage {
}
}

@available(*, unavailable)
extension _SwiftNSMutableArray: Sendable {}

/// An `NSArray` whose contiguous storage is created and filled, upon
/// first access, by bridging the elements of a Swift `Array`.
///
Expand Down Expand Up @@ -435,9 +429,6 @@ extension _SwiftNSMutableArray: Sendable {}
}
}

@available(*, unavailable)
extension __SwiftDeferredNSArray: Sendable {}

/// A `__SwiftDeferredNSArray` which is used for static read-only Swift Arrays.
///
/// In contrast to its base class, `__SwiftDeferredStaticNSArray` is generic
Expand Down Expand Up @@ -593,6 +584,3 @@ internal class __ContiguousArrayStorageBase
self !== _emptyArrayStorage, "Deallocating empty array storage?!")
}
}

@available(*, unavailable)
extension __ContiguousArrayStorageBase: Sendable {}