Skip to content

Commit d70f197

Browse files
committed
[stdlib] Update SwiftStdlibLegacyABI convention to use @available(swift, obsoleted: 1)
Using version `2` here is just weird for no reason.
1 parent 975d7c8 commit d70f197

File tree

7 files changed

+26
-46
lines changed

7 files changed

+26
-46
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public func withUnsafeMutablePointer<
8787
try body(UnsafeMutablePointer<T>(Builtin.addressof(&value)))
8888
}
8989

90-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
90+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
9191
@_silgen_name("$ss24withUnsafeMutablePointer2to_q_xz_q_SpyxGKXEtKr0_lF")
9292
@usableFromInline
9393
internal func __abi_se0413_withUnsafeMutablePointer<T, Result>(
@@ -147,7 +147,7 @@ public func withUnsafePointer<T: ~Copyable, E, Result: ~Copyable>(
147147

148148
/// ABI: Historical withUnsafePointer(to:_:) rethrows, expressed as "throws",
149149
/// which is ABI-compatible with "rethrows".
150-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
150+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
151151
@_silgen_name("$ss17withUnsafePointer2to_q_x_q_SPyxGKXEtKr0_lF")
152152
@usableFromInline
153153
internal func __abi_withUnsafePointer<T, Result>(
@@ -192,7 +192,7 @@ public func withUnsafePointer<T: ~Copyable, E: Error, Result: ~Copyable>(
192192

193193
/// ABI: Historical withUnsafePointer(to:_:) rethrows,
194194
/// expressed as "throws", which is ABI-compatible with "rethrows".
195-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
195+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
196196
@_silgen_name("$ss17withUnsafePointer2to_q_xz_q_SPyxGKXEtKr0_lF")
197197
@usableFromInline
198198
internal func __abi_se0413_withUnsafePointer<T, Result>(

stdlib/public/core/Optional.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public func ?? <T: ~Copyable>(
781781
}
782782
}
783783

784-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
784+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
785785
@usableFromInline
786786
internal func ?? <T>(
787787
optional: T?,
@@ -851,7 +851,7 @@ public func ?? <T: ~Copyable>(
851851
}
852852
}
853853

854-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
854+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
855855
@usableFromInline
856856
internal func ?? <T>(
857857
optional: T?,

stdlib/public/core/Result.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ extension Result where Success: ~Copyable {
131131
}
132132

133133
extension Result {
134-
// TODO: Merge this back into the noncopyable variant once we have @_preInverseGenerics
135-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
134+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
136135
@usableFromInline
137136
internal func mapError<NewFailure>(
138137
_ transform: (Failure) -> NewFailure
@@ -281,7 +280,7 @@ extension Result where Success: ~Copyable {
281280

282281
extension Result {
283282
/// ABI: Historical get() throws
284-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
283+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
285284
@_silgen_name("$ss6ResultO3getxyKF")
286285
@usableFromInline
287286
func __abi_get() throws -> Success {
@@ -297,7 +296,7 @@ extension Result {
297296

298297
extension Result where Failure == Swift.Error {
299298
/// ABI: Historical init(catching:)
300-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
299+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
301300
@_silgen_name("$ss6ResultOss5Error_pRs_rlE8catchingAByxsAC_pGxyKXE_tcfC")
302301
@usableFromInline
303302
init(__abi_catching body: () throws(Failure) -> Success) {

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ extension Unsafe${Mutable}BufferPointer {
518518
%end
519519
}
520520

521-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
521+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
522522
@usableFromInline
523523
internal subscript(_unchecked i: Int) -> Element {
524524
@_transparent
@@ -732,21 +732,13 @@ extension Unsafe${Mutable}BufferPointer where Element: ~Copyable {
732732
/// initialized or `Pointee` must be a trivial type. This buffer pointer's
733733
/// `count` must be equal to the originally allocated size of the memory
734734
/// block.
735-
@_alwaysEmitIntoClient
735+
@inlinable
736+
@_preInverseGenerics
736737
public func deallocate() {
737738
_position?.deallocate()
738739
}
739740
}
740741

741-
extension Unsafe${Mutable}BufferPointer {
742-
// TODO: Merge this back into the noncopyable variant once we have @_preInverseGenerics
743-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
744-
@usableFromInline
745-
internal func deallocate() {
746-
_position?.deallocate()
747-
}
748-
}
749-
750742
% if Mutable:
751743
extension UnsafeMutableBufferPointer where Element: ~Copyable {
752744
/// Allocates uninitialized memory for the specified number of instances of
@@ -770,7 +762,8 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
770762
///
771763
/// - Parameter count: The amount of memory to allocate, counted in instances
772764
/// of `Element`.
773-
@_alwaysEmitIntoClient
765+
@inlinable
766+
@_preInverseGenerics
774767
public static func allocate(
775768
capacity count: Int
776769
) -> UnsafeMutableBufferPointer<Element> {
@@ -779,18 +772,6 @@ extension UnsafeMutableBufferPointer where Element: ~Copyable {
779772
}
780773
}
781774

782-
extension UnsafeMutableBufferPointer {
783-
// TODO: Merge this back into the noncopyable variant once we have @_preInverseGenerics
784-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
785-
@usableFromInline
786-
internal static func allocate(
787-
capacity count: Int
788-
) -> UnsafeMutableBufferPointer<Element> {
789-
let base = UnsafeMutablePointer<Element>.allocate(capacity: count)
790-
return UnsafeMutableBufferPointer(start: base, count: count)
791-
}
792-
}
793-
794775
extension UnsafeMutableBufferPointer {
795776
/// Initializes every element in this buffer's memory to a copy of the given
796777
/// value.
@@ -1319,7 +1300,7 @@ extension Unsafe${Mutable}BufferPointer {
13191300
// of `withMemoryRebound<T, Result>(to:_:)`, and provides
13201301
// an entry point for any binary linked against the stdlib binary
13211302
// for Swift 5.6 and older.
1322-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1303+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
13231304
% if Mutable:
13241305
@_silgen_name("$sSr17withMemoryRebound2to_qd_0_qd__m_qd_0_Sryqd__GKXEtKr0_lF")
13251306
% else:

stdlib/public/core/UnsafePointer.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ extension UnsafePointer {
286286
// This preserves the ABI of the original (pre-6.0) `pointee` property that
287287
// used to export a getter. The current one above would export a read
288288
// accessor, if it wasn't @_alwaysEmitIntoClient.
289-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
289+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
290290
@usableFromInline
291291
internal var pointee: Pointee {
292292
@_transparent unsafeAddress {
@@ -316,7 +316,7 @@ extension UnsafePointer {
316316
// This preserves the ABI of the original (pre-6.0) subscript that used to
317317
// export a getter. The current one above would export a read accessor, if it
318318
// wasn't @_alwaysEmitIntoClient.
319-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
319+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
320320
@usableFromInline
321321
internal subscript(i: Int) -> Pointee {
322322
@_transparent
@@ -415,7 +415,7 @@ extension UnsafePointer {
415415
// of `withMemoryRebound<T, Result>(to:capacity:_:)`, and provides
416416
// an entry point for any binary linked against the stdlib binary
417417
// for Swift 5.6 and older.
418-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
418+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
419419
@_silgen_name("$sSP17withMemoryRebound2to8capacity_qd_0_qd__m_Siqd_0_SPyqd__GKXEtKr0_lF")
420420
@usableFromInline
421421
internal func _legacy_se0333_withMemoryRebound<T, Result>(
@@ -837,7 +837,7 @@ extension UnsafeMutablePointer {
837837
// This preserves the ABI of the original (pre-6.0) `pointee` property that
838838
// used to export a getter. The current one above would export a read
839839
// accessor, if it wasn't @_alwaysEmitIntoClient.
840-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
840+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
841841
@usableFromInline
842842
internal var pointee: Pointee {
843843
@_transparent unsafeAddress {
@@ -893,7 +893,7 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
893893
}
894894

895895
extension UnsafeMutablePointer {
896-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
896+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
897897
@usableFromInline
898898
internal func initialize(to value: Pointee) { // Note: `value` is __shared!
899899
Builtin.initialize(value, self._rawValue)
@@ -1249,7 +1249,7 @@ extension UnsafeMutablePointer {
12491249
// This obsolete implementation uses the expected mangled name of
12501250
// `withMemoryRebound<T, Result>(to:capacity:_:)`, and provides an entry point
12511251
// for any binary linked against the stdlib binary for Swift 5.6 and older.
1252-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1252+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
12531253
@_silgen_name("$sSp17withMemoryRebound2to8capacity_qd_0_qd__m_Siqd_0_Spyqd__GKXEtKr0_lF")
12541254
@usableFromInline
12551255
internal func _legacy_se0333_withMemoryRebound<T, Result>(
@@ -1294,7 +1294,7 @@ extension UnsafeMutablePointer {
12941294
// This preserves the ABI of the original (pre-6.0) subscript that used to
12951295
// export a getter. The current one above would export a read accessor, if it
12961296
// wasn't @_alwaysEmitIntoClient.
1297-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1297+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
12981298
@usableFromInline
12991299
internal subscript(i: Int) -> Pointee {
13001300
@_transparent

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ extension Unsafe${Mutable}RawBufferPointer {
516516
// This unavailable implementation uses the expected mangled name
517517
// of `storeBytes<T>(of:toByteOffset:as:)`, and provides an entry point for
518518
// any binary linked against the stdlib binary for Swift 5.6 and older.
519-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
519+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
520520
@_silgen_name("$sSw10storeBytes2of12toByteOffset2asyx_SixmtlF")
521521
@usableFromInline func _legacy_se0349_storeBytes<T>(
522522
of value: T, toByteOffset offset: Int = 0, as type: T.Type
@@ -1238,7 +1238,7 @@ public func withUnsafeMutableBytes<T: ~Copyable, E: Error, Result: ~Copyable>(
12381238

12391239
/// ABI: Historical withUnsafeMutableBytes(of:_:) rethrows,
12401240
/// expressed as "throws", which is ABI-compatible with "rethrows".
1241-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1241+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
12421242
@_silgen_name("$ss22withUnsafeMutableBytes2of_q_xz_q_SwKXEtKr0_lF")
12431243
@usableFromInline
12441244
func __abi_se0413_withUnsafeMutableBytes<T, Result>(
@@ -1305,7 +1305,7 @@ public func withUnsafeBytes<T: ~Copyable, E: Error, Result: ~Copyable>(
13051305

13061306
/// ABI: Historical withUnsafeBytes(of:_:) rethrows,
13071307
/// expressed as "throws", which is ABI-compatible with "rethrows".
1308-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1308+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
13091309
@_silgen_name("$ss15withUnsafeBytes2of_q_xz_q_SWKXEtKr0_lF")
13101310
@usableFromInline
13111311
func __abi_se0413_withUnsafeBytes<T, Result>(
@@ -1369,7 +1369,7 @@ public func withUnsafeBytes<
13691369

13701370
/// ABI: Historical withUnsafeBytes(of:_:) rethrows,
13711371
/// expressed as "throws", which is ABI-compatible with "rethrows".
1372-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1372+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
13731373
@_silgen_name("$ss15withUnsafeBytes2of_q_x_q_SWKXEtKr0_lF")
13741374
@usableFromInline
13751375
func __abi_se0413_withUnsafeBytes<T, Result>(

stdlib/public/core/UnsafeRawPointer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ extension UnsafeMutableRawPointer {
14821482
// This obsolete implementation uses the expected mangled name
14831483
// of `storeBytes<T>(of:toByteOffset:as:)`, and provides an entry point for
14841484
// any binary compiled against the stdlib binary for Swift 5.6 and older.
1485-
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 2)
1485+
@_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1)
14861486
@_silgen_name("$sSv10storeBytes2of12toByteOffset2asyx_SixmtlF")
14871487
@usableFromInline func _legacy_se0349_storeBytes<T>(
14881488
of value: T, toByteOffset offset: Int = 0, as type: T.Type

0 commit comments

Comments
 (0)