Skip to content

Commit 30a76d7

Browse files
authored
Merge pull request #72301 from tshortli/with-memory-rebound-typed-throws-condfail
stdlib: Guard `@inlinable` use of `withMemoryRebound()` with `#if $TypedThrows`
2 parents 7ac7d55 + 20a8399 commit 30a76d7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ extension Unsafe${Mutable}RawBufferPointer {
11331133
public func withContiguousMutableStorageIfAvailable<R>(
11341134
_ body: (inout UnsafeMutableBufferPointer<Element>) throws -> R
11351135
) rethrows -> R? {
1136+
#if $TypedThrows
11361137
try withMemoryRebound(to: Element.self) { b in
11371138
var buffer = b
11381139
defer {
@@ -1143,6 +1144,9 @@ extension Unsafe${Mutable}RawBufferPointer {
11431144
}
11441145
return try body(&buffer)
11451146
}
1147+
#else
1148+
fatalError("unsupported compiler")
1149+
#endif
11461150
}
11471151

11481152
% end
@@ -1151,9 +1155,13 @@ extension Unsafe${Mutable}RawBufferPointer {
11511155
public func withContiguousStorageIfAvailable<R>(
11521156
_ body: (UnsafeBufferPointer<Element>) throws -> R
11531157
) rethrows -> R? {
1158+
#if $TypedThrows
11541159
try withMemoryRebound(to: Element.self) {
11551160
try body(${ 'UnsafeBufferPointer<Element>($0)' if Mutable else '$0' })
11561161
}
1162+
#else
1163+
fatalError("unsupported compiler")
1164+
#endif
11571165
}
11581166
}
11591167

0 commit comments

Comments
 (0)