Skip to content

Commit c2d69a6

Browse files
committed
[stdlib] Remove workarounds for certain builtins not supporting noncopyable use
#71733 fixed this!
1 parent 11cf4ff commit c2d69a6

File tree

1 file changed

+0
-76
lines changed

1 file changed

+0
-76
lines changed

stdlib/public/core/UnsafePointer.swift

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,6 @@ extension UnsafeMutablePointer {
905905
}
906906
}
907907

908-
#if true // Builtin.initialize doesn't support noncopyable types (rdar://123253877)
909-
extension UnsafeMutablePointer {
910-
@_alwaysEmitIntoClient
911-
public func initialize(to value: consuming Pointee) {
912-
Builtin.initialize(value, self._rawValue)
913-
}
914-
}
915-
#else
916908
extension UnsafeMutablePointer where Pointee: ~Copyable {
917909
/// Initializes this pointer's memory with a single instance of the given
918910
/// value.
@@ -937,7 +929,6 @@ extension UnsafeMutablePointer {
937929
Builtin.initialize(value, self._rawValue)
938930
}
939931
}
940-
#endif
941932

942933
extension UnsafeMutablePointer where Pointee: ~Copyable {
943934
/// Retrieves and returns the referenced instance, returning the pointer's
@@ -1055,37 +1046,6 @@ extension UnsafeMutablePointer {
10551046
}
10561047
}
10571048

1058-
#if true // Builtin.takeArray* don't support noncopyable types (rdar://123253877)
1059-
extension UnsafeMutablePointer {
1060-
@_alwaysEmitIntoClient
1061-
public func moveInitialize(
1062-
@_nonEphemeral from source: UnsafeMutablePointer, count: Int
1063-
) {
1064-
_debugPrecondition(
1065-
count >= 0, "UnsafeMutablePointer.moveInitialize with negative count")
1066-
if self < source || self >= source + count {
1067-
// initialize forward from a disjoint or following overlapping range.
1068-
Builtin.takeArrayFrontToBack(
1069-
Pointee.self, self._rawValue, source._rawValue, count._builtinWordValue)
1070-
// This builtin is equivalent to:
1071-
// for i in 0..<count {
1072-
// (self + i).initialize(to: (source + i).move())
1073-
// }
1074-
}
1075-
else if self != source {
1076-
// initialize backward from a non-following overlapping range.
1077-
Builtin.takeArrayBackToFront(
1078-
Pointee.self, self._rawValue, source._rawValue, count._builtinWordValue)
1079-
// This builtin is equivalent to:
1080-
// var src = source + count
1081-
// var dst = self + count
1082-
// while dst != self {
1083-
// (--dst).initialize(to: (--src).move())
1084-
// }
1085-
}
1086-
}
1087-
}
1088-
#else
10891049
extension UnsafeMutablePointer where Pointee: ~Copyable {
10901050
/// Moves instances from initialized source memory into the uninitialized
10911051
/// memory referenced by this pointer, leaving the source memory
@@ -1165,7 +1125,6 @@ extension UnsafeMutablePointer {
11651125
}
11661126
}
11671127
}
1168-
#endif
11691128

11701129
extension UnsafeMutablePointer {
11711130
/// Initializes the memory referenced by this pointer with the values
@@ -1201,26 +1160,6 @@ extension UnsafeMutablePointer {
12011160
}
12021161
}
12031162

1204-
#if true // Builtin.assignTakeArray doesn't support noncopyable types (rdar://123253877)
1205-
extension UnsafeMutablePointer {
1206-
@_alwaysEmitIntoClient
1207-
public func moveUpdate(
1208-
@_nonEphemeral from source: UnsafeMutablePointer, count: Int
1209-
) {
1210-
_debugPrecondition(
1211-
count >= 0, "UnsafeMutablePointer.moveUpdate(from:) with negative count")
1212-
_debugPrecondition(
1213-
self + count <= source || source + count <= self,
1214-
"moveUpdate overlapping range")
1215-
Builtin.assignTakeArray(
1216-
Pointee.self, self._rawValue, source._rawValue, count._builtinWordValue)
1217-
// These builtins are equivalent to:
1218-
// for i in 0..<count {
1219-
// self[i] = (source + i).move()
1220-
// }
1221-
}
1222-
}
1223-
#else
12241163
extension UnsafeMutablePointer where Pointee: ~Copyable {
12251164
/// Update this pointer's initialized memory by moving the specified number
12261165
/// of instances the source pointer's memory, leaving the source memory
@@ -1288,21 +1227,7 @@ extension UnsafeMutablePointer {
12881227
moveUpdate(from: source, count: count)
12891228
}
12901229
}
1291-
#endif
12921230

1293-
#if true // Builtin.destroyArray doesn't support noncopyable types (rdar://123253877)
1294-
extension UnsafeMutablePointer {
1295-
@_alwaysEmitIntoClient
1296-
@discardableResult
1297-
public func deinitialize(count: Int) -> UnsafeMutableRawPointer {
1298-
_debugPrecondition(count >= 0, "UnsafeMutablePointer.deinitialize with negative count")
1299-
// TODO: IRGen optimization when `count` value is statically known to be 1,
1300-
// then call `Builtin.destroy(Pointee.self, _rawValue)` instead.
1301-
Builtin.destroyArray(Pointee.self, _rawValue, count._builtinWordValue)
1302-
return UnsafeMutableRawPointer(self)
1303-
}
1304-
}
1305-
#else
13061231
extension UnsafeMutablePointer where Pointee: ~Copyable {
13071232
/// Deinitializes the specified number of values starting at this pointer.
13081233
///
@@ -1338,7 +1263,6 @@ extension UnsafeMutablePointer {
13381263
return UnsafeMutableRawPointer(self)
13391264
}
13401265
}
1341-
#endif
13421266

13431267
extension UnsafeMutablePointer /* where Pointee: ~Copyable */ {
13441268
// FIXME: We want this to have the constraint above, but that triggers a .swiftinterface issue.

0 commit comments

Comments
 (0)