@@ -166,11 +166,22 @@ func __abi_withUnsafePointer<T, Result>(
166166/// `withUnsafeMutablePointer(to:_:)` instead.
167167/// - Returns: The return value, if any, of the `body` closure.
168168@inlinable
169- public func withUnsafePointer< T, Result> (
169+ @_alwaysEmitIntoClient
170+ public func withUnsafePointer< T, E: Error , Result> (
171+ to value: inout T ,
172+ _ body: ( UnsafePointer < T > ) throws ( E ) -> Result
173+ ) throws ( E) -> Result {
174+ try body ( UnsafePointer < T > ( Builtin . addressof ( & value) ) )
175+ }
176+
177+ /// ABI: Historical withUnsafePointer(to:_:) rethrows,
178+ /// expressed as "throws", which is ABI-compatible with "rethrows".
179+ @_silgen_name ( " $ss17withUnsafePointer2to_q_xz_q_SPyxGKXEtKr0_lF " )
180+ @usableFromInline
181+ func __abi_se0413_withUnsafePointer< T, Result> (
170182 to value: inout T ,
171183 _ body: ( UnsafePointer < T > ) throws -> Result
172- ) rethrows -> Result
173- {
184+ ) throws -> Result {
174185 return try body ( UnsafePointer < T > ( Builtin . addressof ( & value) ) )
175186}
176187
@@ -179,11 +190,10 @@ public func withUnsafePointer<T, Result>(
179190/// This function is similar to `withUnsafePointer`, except that it
180191/// doesn't trigger stack protection for the pointer.
181192@_alwaysEmitIntoClient
182- public func _withUnprotectedUnsafePointer< T, Result> (
193+ public func _withUnprotectedUnsafePointer< T, E : Error , Result> (
183194 to value: inout T ,
184- _ body: ( UnsafePointer < T > ) throws -> Result
185- ) rethrows -> Result
186- {
195+ _ body: ( UnsafePointer < T > ) throws ( E ) -> Result
196+ ) throws ( E) -> Result {
187197#if $BuiltinUnprotectedAddressOf
188198 return try body ( UnsafePointer < T > ( Builtin . unprotectedAddressOf ( & value) ) )
189199#else
0 commit comments