Skip to content

Commit 4dc9713

Browse files
committed
[stdlib] Uncheck pointers' conf to BitwiseCopyable
The pitch calls for such types to obstruct inference of _BitwiseCopyable in aggregates containing them.
1 parent 0ae0fdc commit 4dc9713

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

stdlib/public/core/BridgeObjectiveC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public func _getBridgedNonVerbatimObjectiveCType<T>(_: T.Type) -> Any.Type?
407407
/// already have writeback-scoped lifetime.
408408
@frozen
409409
public struct AutoreleasingUnsafeMutablePointer<Pointee /* TODO : class */>
410-
: _Pointer {
410+
: _Pointer, @unchecked _BitwiseCopyable {
411411

412412
public let _rawValue: Builtin.RawPointer
413413

stdlib/public/core/CTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public typealias CBool = Bool
142142
/// Opaque pointers are used to represent C pointers to types that
143143
/// cannot be represented in Swift, such as incomplete struct types.
144144
@frozen
145-
public struct OpaquePointer {
145+
public struct OpaquePointer : @unchecked _BitwiseCopyable {
146146
@usableFromInline
147147
internal var _rawValue: Builtin.RawPointer
148148

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
/// collection with an `${Self}` instance copies the instances out of the
3131
/// referenced memory and into the new collection.
3232
@frozen // unsafe-performance
33-
public struct Unsafe${Mutable}BufferPointer<Element> {
33+
public struct Unsafe${Mutable}BufferPointer<Element>
34+
: @unchecked _BitwiseCopyable {
3435

3536
@usableFromInline
3637
let _position: Unsafe${Mutable}Pointer<Element>?

stdlib/public/core/UnsafePointer.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
/// let numberPointer = UnsafePointer<Int>(&number)
206206
/// // Accessing 'numberPointer' is undefined behavior.
207207
@frozen // unsafe-performance
208-
public struct UnsafePointer<Pointee>: _Pointer {
208+
public struct UnsafePointer<Pointee>: _Pointer, @unchecked _BitwiseCopyable {
209209

210210
/// A type that represents the distance between two pointers.
211211
public typealias Distance = Int
@@ -578,7 +578,8 @@ public struct UnsafePointer<Pointee>: _Pointer {
578578
/// let numberPointer = UnsafeMutablePointer<Int>(&number)
579579
/// // Accessing 'numberPointer' is undefined behavior.
580580
@frozen // unsafe-performance
581-
public struct UnsafeMutablePointer<Pointee>: _Pointer {
581+
public struct UnsafeMutablePointer<Pointee>
582+
: _Pointer, @unchecked _BitwiseCopyable {
582583

583584
/// A type that represents the distance between two pointers.
584585
public typealias Distance = Int

stdlib/public/core/UnsafeRawPointer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
/// let numberPointer = UnsafeRawPointer(&number)
170170
/// // Accessing 'numberPointer' is undefined behavior.
171171
@frozen
172-
public struct UnsafeRawPointer: _Pointer {
172+
public struct UnsafeRawPointer: _Pointer, @unchecked _BitwiseCopyable {
173173

174174
public typealias Pointee = UInt8
175175

@@ -727,7 +727,7 @@ extension UnsafeRawPointer {
727727
/// let numberPointer = UnsafeMutableRawPointer(&number)
728728
/// // Accessing 'numberPointer' is undefined behavior.
729729
@frozen
730-
public struct UnsafeMutableRawPointer: _Pointer {
730+
public struct UnsafeMutableRawPointer: _Pointer, @unchecked _BitwiseCopyable {
731731

732732
public typealias Pointee = UInt8
733733

test/SourceKit/DocSupport/doc_clang_module.swift.response

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,11 @@ var FooSubUnnamedEnumeratorA1: Int { get }
56545654
key.kind: source.lang.swift.ref.protocol,
56555655
key.name: "_Pointer",
56565656
key.usr: "s:s8_PointerP"
5657+
},
5658+
{
5659+
key.kind: source.lang.swift.ref.protocol,
5660+
key.name: "_BitwiseCopyable",
5661+
key.usr: "s:s16_BitwiseCopyableP"
56575662
}
56585663
]
56595664
},

0 commit comments

Comments
 (0)