Skip to content
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

Unsafe*Pointer types should not be Sendable. #39218

Merged
merged 2 commits into from
Dec 7, 2021
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
2 changes: 1 addition & 1 deletion stdlib/public/core/BridgeObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ extension UnsafeRawPointer {
}
}

extension AutoreleasingUnsafeMutablePointer: Sendable { }
extension AutoreleasingUnsafeMutablePointer { }

internal struct _CocoaFastEnumerationStackBuf {
// Clang uses 16 pointers. So do we.
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/CTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public typealias CBool = Bool
/// Opaque pointers are used to represent C pointers to types that
/// cannot be represented in Swift, such as incomplete struct types.
@frozen
public struct OpaquePointer: Sendable {
public struct OpaquePointer {
@usableFromInline
internal var _rawValue: Builtin.RawPointer

Expand Down Expand Up @@ -235,7 +235,7 @@ extension UInt {
/// A wrapper around a C `va_list` pointer.
#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))
@frozen
public struct CVaListPointer: Sendable {
public struct CVaListPointer {
@usableFromInline // unsafe-performance
internal var _value: (__stack: UnsafeMutablePointer<Int>?,
__gr_top: UnsafeMutablePointer<Int>?,
Expand Down
4 changes: 0 additions & 4 deletions stdlib/public/core/UnsafeBufferPointer.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,6 @@ extension UnsafeMutableBufferPointer {
}
}

extension UnsafeBufferPointer: Sendable { }
extension UnsafeBufferPointer.Iterator: Sendable { }
extension UnsafeMutableBufferPointer: Sendable { }

// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End:
4 changes: 2 additions & 2 deletions stdlib/public/core/UnsafePointer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
/// let numberPointer = UnsafePointer<Int>(&number)
/// // Accessing 'numberPointer' is undefined behavior.
@frozen // unsafe-performance
public struct UnsafePointer<Pointee>: _Pointer, Sendable {
public struct UnsafePointer<Pointee>: _Pointer {

/// A type that represents the distance between two pointers.
public typealias Distance = Int
Expand Down Expand Up @@ -511,7 +511,7 @@ public struct UnsafePointer<Pointee>: _Pointer, Sendable {
/// let numberPointer = UnsafeMutablePointer<Int>(&number)
/// // Accessing 'numberPointer' is undefined behavior.
@frozen // unsafe-performance
public struct UnsafeMutablePointer<Pointee>: _Pointer, Sendable {
public struct UnsafeMutablePointer<Pointee>: _Pointer {

/// A type that represents the distance between two pointers.
public typealias Distance = Int
Expand Down
5 changes: 0 additions & 5 deletions stdlib/public/core/UnsafeRawBufferPointer.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,6 @@ public func withUnsafeBytes<T, Result>(
return try body(buffer)
}

extension UnsafeRawBufferPointer: Sendable { }
extension UnsafeRawBufferPointer.Iterator: Sendable { }
extension UnsafeMutableRawBufferPointer: Sendable { }


// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End:
4 changes: 2 additions & 2 deletions stdlib/public/core/UnsafeRawPointer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
/// let numberPointer = UnsafeRawPointer(&number)
/// // Accessing 'numberPointer' is undefined behavior.
@frozen
public struct UnsafeRawPointer: _Pointer, Sendable {
public struct UnsafeRawPointer: _Pointer {

public typealias Pointee = UInt8

Expand Down Expand Up @@ -527,7 +527,7 @@ extension UnsafeRawPointer: Strideable {
/// let numberPointer = UnsafeMutableRawPointer(&number)
/// // Accessing 'numberPointer' is undefined behavior.
@frozen
public struct UnsafeMutableRawPointer: _Pointer, Sendable {
public struct UnsafeMutableRawPointer: _Pointer {

public typealias Pointee = UInt8

Expand Down
5 changes: 0 additions & 5 deletions test/SourceKit/DocSupport/doc_clang_module.swift.response
Original file line number Diff line number Diff line change
Expand Up @@ -5591,11 +5591,6 @@ var FooSubUnnamedEnumeratorA1: Int { get }
key.kind: source.lang.swift.ref.protocol,
key.name: "_Pointer",
key.usr: "s:s8_PointerP"
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Sendable",
key.usr: "s:s8SendableP"
}
]
},
Expand Down