Skip to content

Commit 78273b2

Browse files
authored
Merge pull request #72089 from glessard/toplevel-withUMP-typed-throws
[stdlib] convert `withUnsafeMutablePointer()` to typed throws
2 parents b17f0b5 + 3f9d93d commit 78273b2

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,20 @@ public func _fixLifetime<T>(_ x: T) {
7474
/// execution.
7575
/// - Returns: The return value, if any, of the `body` closure.
7676
@inlinable
77-
public func withUnsafeMutablePointer<T, Result>(
77+
@_alwaysEmitIntoClient
78+
public func withUnsafeMutablePointer<T, E: Error, Result>(
79+
to value: inout T,
80+
_ body: (UnsafeMutablePointer<T>) throws(E) -> Result
81+
) throws(E) -> Result {
82+
try body(UnsafeMutablePointer<T>(Builtin.addressof(&value)))
83+
}
84+
85+
@_silgen_name("$ss24withUnsafeMutablePointer2to_q_xz_q_SpyxGKXEtKr0_lF")
86+
@usableFromInline
87+
func __abi_se0413_withUnsafeMutablePointer<T, Result>(
7888
to value: inout T,
7989
_ body: (UnsafeMutablePointer<T>) throws -> Result
80-
) rethrows -> Result
81-
{
90+
) throws -> Result {
8291
return try body(UnsafeMutablePointer<T>(Builtin.addressof(&value)))
8392
}
8493

test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Func Collection.map(_:) is now without @rethrows
4141
Func Sequence.map(_:) has generic signature change from <Self, T where Self : Swift.Sequence> to <Self, T, E where Self : Swift.Sequence, E : Swift.Error>
4242
Func Sequence.map(_:) is now without @rethrows
4343
Constructor Result.init(catching:) has generic signature change from <Success, Failure where Failure == any Swift.Error> to <Success, Failure where Failure : Swift.Error>
44+
Func withUnsafeMutablePointer(to:_:) has generic signature change from <T, Result> to <T, E, Result where E : Swift.Error>
45+
Func withUnsafeMutablePointer(to:_:) is now without @rethrows
4446
Func withUnsafePointer(to:_:) has generic signature change from <T, Result> to <T, E, Result where E : Swift.Error>
4547
Func withUnsafePointer(to:_:) is now without @rethrows
4648
Func withUnsafeBytes(of:_:) has generic signature change from <T, Result> to <T, E, Result where E : Swift.Error>

test/api-digester/stability-stdlib-abi-without-asserts.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ Constructor Result.init(__abi_catching:) is a new API without @available attribu
105105
Constructor Result.init(catching:) has been removed
106106
Func Result.get() has been renamed to Func __abi_get()
107107
Func Result.get() has mangled name changing from 'Swift.Result.get() throws -> A' to 'Swift.Result.__abi_get() throws -> A'
108+
Func withUnsafeMutablePointer(to:_:) has been renamed to Func __abi_se0413_withUnsafeMutablePointer(to:_:)
109+
Func withUnsafeMutablePointer(to:_:) has mangled name changing from 'Swift.withUnsafeMutablePointer<A, B>(to: inout A, _: (Swift.UnsafeMutablePointer<A>) throws -> B) throws -> B' to 'Swift.__abi_se0413_withUnsafeMutablePointer<A, B>(to: inout A, _: (Swift.UnsafeMutablePointer<A>) throws -> B) throws -> B'
110+
Func withUnsafeMutablePointer(to:_:) is now without @rethrows
108111
Func withUnsafePointer(to:_:) has been renamed to Func __abi_withUnsafePointer(to:_:)
109112
Func withUnsafePointer(to:_:) has mangled name changing from 'Swift.withUnsafePointer<A, B>(to: A, _: (Swift.UnsafePointer<A>) throws -> B) throws -> B' to 'Swift.__abi_withUnsafePointer<A, B>(to: A, _: (Swift.UnsafePointer<A>) throws -> B) throws -> B'
110113
Func withUnsafePointer(to:_:) has been renamed to Func __abi_se0413_withUnsafePointer(to:_:)

0 commit comments

Comments
 (0)