@@ -227,14 +227,30 @@ extension UnsafePointer: _Pointer where Pointee: ~Copyable {
227
227
public typealias Distance = Int
228
228
}
229
229
230
- extension UnsafePointer {
231
- // Note: This explicit `hashValue` applies @_preInverseGenerics to the
230
+ @_preInverseGenerics
231
+ extension UnsafePointer : Equatable where Pointee: ~ Copyable { }
232
+ @_preInverseGenerics
233
+ extension UnsafePointer : Hashable where Pointee: ~ Copyable {
234
+ // Note: This explicit `hashValue` applies @_preInverseGenerics to emulate the
232
235
// original (pre-6.0) compiler-synthesized version.
233
236
@_preInverseGenerics
234
237
public var hashValue : Int {
235
238
_hashValue ( for: self )
236
239
}
237
240
}
241
+ @_preInverseGenerics
242
+ extension UnsafePointer : Comparable where Pointee: ~ Copyable { }
243
+ @_preInverseGenerics
244
+ extension UnsafePointer : Strideable where Pointee: ~ Copyable { }
245
+ #if !$Embedded
246
+ @_preInverseGenerics
247
+ extension UnsafePointer : CustomDebugStringConvertible
248
+ where Pointee: ~ Copyable { }
249
+ #endif
250
+ #if SWIFT_ENABLE_REFLECTION
251
+ @_preInverseGenerics
252
+ extension UnsafePointer : CustomReflectable where Pointee: ~ Copyable { }
253
+ #endif
238
254
239
255
extension UnsafePointer where Pointee: ~ Copyable {
240
256
/// Deallocates the memory block previously allocated at this pointer.
@@ -258,15 +274,27 @@ extension UnsafePointer where Pointee: ~Copyable {
258
274
///
259
275
/// When reading from the `pointee` property, the instance referenced by
260
276
/// this pointer must already be initialized.
261
- @inlinable
262
- @_preInverseGenerics
277
+ @_alwaysEmitIntoClient
263
278
public var pointee : Pointee {
264
279
@_transparent unsafeAddress {
265
280
return self
266
281
}
267
282
}
268
283
}
269
284
285
+ extension UnsafePointer {
286
+ // This preserves the ABI of the original (pre-6.0) `pointee` property that
287
+ // used to export a getter. The current one above would export a read
288
+ // accessor, if it wasn't @_alwaysEmitIntoClient.
289
+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 2 )
290
+ @usableFromInline
291
+ internal var pointee : Pointee {
292
+ @_transparent unsafeAddress {
293
+ return self
294
+ }
295
+ }
296
+ }
297
+
270
298
extension UnsafePointer where Pointee: ~ Copyable {
271
299
/// Accesses the pointee at the specified offset from this pointer.
272
300
///
@@ -275,8 +303,7 @@ extension UnsafePointer where Pointee: ~Copyable {
275
303
///
276
304
/// - Parameter i: The offset from this pointer at which to access an
277
305
/// instance, measured in strides of the pointer's `Pointee` type.
278
- @inlinable
279
- @_preInverseGenerics
306
+ @_alwaysEmitIntoClient
280
307
public subscript( i: Int ) -> Pointee {
281
308
@_transparent
282
309
unsafeAddress {
@@ -285,6 +312,20 @@ extension UnsafePointer where Pointee: ~Copyable {
285
312
}
286
313
}
287
314
315
+ extension UnsafePointer {
316
+ // This preserves the ABI of the original (pre-6.0) subscript that used to
317
+ // export a getter. The current one above would export a read accessor, if it
318
+ // wasn't @_alwaysEmitIntoClient.
319
+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 2 )
320
+ @usableFromInline
321
+ internal subscript( i: Int ) -> Pointee {
322
+ @_transparent
323
+ unsafeAddress {
324
+ return self + i
325
+ }
326
+ }
327
+ }
328
+
288
329
extension UnsafePointer where Pointee: ~ Copyable {
289
330
/// Executes the given closure while temporarily binding memory to
290
331
/// the specified number of instances of type `T`.
@@ -631,6 +672,31 @@ extension UnsafeMutablePointer: _Pointer where Pointee: ~Copyable {
631
672
public typealias Distance = Int
632
673
}
633
674
675
+ @_preInverseGenerics
676
+ extension UnsafeMutablePointer : Equatable where Pointee: ~ Copyable { }
677
+ @_preInverseGenerics
678
+ extension UnsafeMutablePointer : Hashable where Pointee: ~ Copyable {
679
+ // Note: This explicit `hashValue` applies @_preInverseGenerics to emulate the
680
+ // original (pre-6.0) compiler-synthesized version.
681
+ @_preInverseGenerics
682
+ public var hashValue : Int {
683
+ _hashValue ( for: self )
684
+ }
685
+ }
686
+ @_preInverseGenerics
687
+ extension UnsafeMutablePointer : Comparable where Pointee: ~ Copyable { }
688
+ @_preInverseGenerics
689
+ extension UnsafeMutablePointer : Strideable where Pointee: ~ Copyable { }
690
+ #if !$Embedded
691
+ @_preInverseGenerics
692
+ extension UnsafeMutablePointer : CustomDebugStringConvertible
693
+ where Pointee: ~ Copyable { }
694
+ #endif
695
+ #if SWIFT_ENABLE_REFLECTION
696
+ @_preInverseGenerics
697
+ extension UnsafeMutablePointer : CustomReflectable where Pointee: ~ Copyable { }
698
+ #endif
699
+
634
700
extension UnsafeMutablePointer where Pointee: ~ Copyable {
635
701
/// Creates a mutable typed pointer referencing the same memory as the given
636
702
/// immutable pointer.
@@ -677,15 +743,6 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
677
743
}
678
744
}
679
745
680
- extension UnsafeMutablePointer {
681
- // Note: This explicit `hashValue` applies @_preInverseGenerics to the
682
- // original (pre-6.0) compiler-synthesized version.
683
- @_preInverseGenerics
684
- public var hashValue : Int {
685
- _hashValue ( for: self )
686
- }
687
- }
688
-
689
746
extension UnsafeMutablePointer where Pointee: ~ Copyable {
690
747
/// Allocates uninitialized memory for the specified number of instances of
691
748
/// type `Pointee`.
@@ -765,8 +822,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
765
822
/// Uninitialized memory cannot be initialized to a nontrivial type
766
823
/// using `pointee`. Instead, use an initializing method, such as
767
824
/// `initialize(to:)`.
768
- @inlinable // unsafe-performance
769
- @_preInverseGenerics
825
+ @_alwaysEmitIntoClient
770
826
public var pointee : Pointee {
771
827
@_transparent unsafeAddress {
772
828
return UnsafePointer ( self )
@@ -777,6 +833,23 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
777
833
}
778
834
}
779
835
836
+ extension UnsafeMutablePointer {
837
+ // This preserves the ABI of the original (pre-6.0) `pointee` property that
838
+ // used to export a getter. The current one above would export a read
839
+ // accessor, if it wasn't @_alwaysEmitIntoClient.
840
+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 2 )
841
+ @usableFromInline
842
+ internal var pointee : Pointee {
843
+ @_transparent unsafeAddress {
844
+ return UnsafePointer ( self )
845
+ }
846
+ @_transparent nonmutating unsafeMutableAddress {
847
+ return self
848
+ }
849
+ }
850
+ }
851
+
852
+
780
853
extension UnsafeMutablePointer {
781
854
/// Initializes this pointer's memory with the specified number of
782
855
/// consecutive copies of the given value.
@@ -952,7 +1025,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
952
1025
/// referenced by `source` and this pointer may overlap.
953
1026
/// - count: The number of instances to move from `source` to this
954
1027
/// pointer's memory. `count` must not be negative.
955
- @_alwaysEmitIntoClient
1028
+ @inlinable
956
1029
@_preInverseGenerics
957
1030
public func moveInitialize(
958
1031
@_nonEphemeral from source: UnsafeMutablePointer , count: Int
@@ -1036,6 +1109,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
1036
1109
/// - count: The number of instances to move from `source` to this
1037
1110
/// pointer's memory. `count` must not be negative.
1038
1111
@inlinable
1112
+ @_silgen_name ( " $sSp10moveAssign4from5countySpyxG_SitF " )
1039
1113
@_preInverseGenerics
1040
1114
public func moveUpdate(
1041
1115
@_nonEphemeral from source: UnsafeMutablePointer , count: Int
@@ -1203,8 +1277,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
1203
1277
///
1204
1278
/// - Parameter i: The offset from this pointer at which to access an
1205
1279
/// instance, measured in strides of the pointer's `Pointee` type.
1206
- @inlinable
1207
- @_preInverseGenerics
1280
+ @_alwaysEmitIntoClient
1208
1281
public subscript( i: Int ) -> Pointee {
1209
1282
@_transparent
1210
1283
unsafeAddress {
@@ -1217,6 +1290,24 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
1217
1290
}
1218
1291
}
1219
1292
1293
+ extension UnsafeMutablePointer {
1294
+ // This preserves the ABI of the original (pre-6.0) subscript that used to
1295
+ // export a getter. The current one above would export a read accessor, if it
1296
+ // wasn't @_alwaysEmitIntoClient.
1297
+ @_spi ( SwiftStdlibLegacyABI) @available ( swift, obsoleted: 2 )
1298
+ @usableFromInline
1299
+ internal subscript( i: Int ) -> Pointee {
1300
+ @_transparent
1301
+ unsafeAddress {
1302
+ return UnsafePointer ( self + i)
1303
+ }
1304
+ @_transparent
1305
+ nonmutating unsafeMutableAddress {
1306
+ return self + i
1307
+ }
1308
+ }
1309
+ }
1310
+
1220
1311
extension UnsafeMutablePointer {
1221
1312
/// Obtain a pointer to the stored property referred to by a key path.
1222
1313
///
0 commit comments