@@ -166,11 +166,22 @@ func __abi_withUnsafePointer<T, Result>(
166
166
/// `withUnsafeMutablePointer(to:_:)` instead.
167
167
/// - Returns: The return value, if any, of the `body` closure.
168
168
@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> (
170
182
to value: inout T ,
171
183
_ body: ( UnsafePointer < T > ) throws -> Result
172
- ) rethrows -> Result
173
- {
184
+ ) throws -> Result {
174
185
return try body ( UnsafePointer < T > ( Builtin . addressof ( & value) ) )
175
186
}
176
187
@@ -179,11 +190,10 @@ public func withUnsafePointer<T, Result>(
179
190
/// This function is similar to `withUnsafePointer`, except that it
180
191
/// doesn't trigger stack protection for the pointer.
181
192
@_alwaysEmitIntoClient
182
- public func _withUnprotectedUnsafePointer< T, Result> (
193
+ public func _withUnprotectedUnsafePointer< T, E : Error , Result> (
183
194
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 {
187
197
#if $BuiltinUnprotectedAddressOf
188
198
return try body ( UnsafePointer < T > ( Builtin . unprotectedAddressOf ( & value) ) )
189
199
#else
0 commit comments