Skip to content

Commit 3a27456

Browse files
committed
stdlib: Add unavailable declarations for withUnsafeMutablePointers
1 parent 31700c7 commit 3a27456

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,50 @@ public func withUnsafePointer<T, Result>(
9595
{
9696
Builtin.unreachable()
9797
}
98+
99+
@available(*, unavailable, message:"use nested withUnsafeMutablePointer(to:_:) instead")
100+
public func withUnsafeMutablePointers<A0, A1, Result>(
101+
_ arg0: inout A0,
102+
_ arg1: inout A1,
103+
_ body: @noescape (
104+
UnsafeMutablePointer<A0>, UnsafeMutablePointer<A1>) throws -> Result
105+
) rethrows -> Result {
106+
Builtin.unreachable()
107+
}
108+
109+
@available(*, unavailable, message:"use nested withUnsafeMutablePointer(to:_:) instead")
110+
public func withUnsafeMutablePointers<A0, A1, A2, Result>(
111+
_ arg0: inout A0,
112+
_ arg1: inout A1,
113+
_ arg2: inout A2,
114+
_ body: @noescape (
115+
UnsafeMutablePointer<A0>,
116+
UnsafeMutablePointer<A1>,
117+
UnsafeMutablePointer<A2>
118+
) throws -> Result
119+
) rethrows -> Result {
120+
Builtin.unreachable()
121+
}
122+
123+
@available(*, unavailable, message:"use nested withUnsafePointer(to:_:) instead")
124+
public func withUnsafePointers<A0, A1, Result>(
125+
_ arg0: inout A0,
126+
_ arg1: inout A1,
127+
_ body: (UnsafePointer<A0>, UnsafePointer<A1>) throws -> Result
128+
) rethrows -> Result {
129+
Builtin.unreachable()
130+
}
131+
132+
@available(*, unavailable, message:"use nested withUnsafePointer(to:_:) instead")
133+
public func withUnsafePointers<A0, A1, A2, Result>(
134+
_ arg0: inout A0,
135+
_ arg1: inout A1,
136+
_ arg2: inout A2,
137+
_ body: (
138+
UnsafePointer<A0>,
139+
UnsafePointer<A1>,
140+
UnsafePointer<A2>
141+
) throws -> Result
142+
) rethrows -> Result {
143+
Builtin.unreachable()
144+
}

test/1_stdlib/Renames.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ func _LazySequence<S : LazySequenceProtocol>(s: S) {
266266
_ = s.array // expected-error {{'array' is unavailable: Please use Array initializer instead.}} {{none}}
267267
}
268268

269+
func _LifetimeManager<T>(x: T) {
270+
var x = x
271+
_ = withUnsafeMutablePointer(&x) { _ in } // expected-error {{'withUnsafeMutablePointer' has been renamed to 'withUnsafeMutablePointer(to:_:)'}} {{7-31=withUnsafeMutablePointer}} {{32-32=to: }} {{none}}
272+
_ = withUnsafeMutablePointers(&x, &x) { _, _ in } // expected-error {{'withUnsafeMutablePointers' is unavailable: use nested withUnsafeMutablePointer(to:_:) instead}} {{none}}
273+
_ = withUnsafeMutablePointers(&x, &x, &x) { _, _, _ in } // expected-error {{'withUnsafeMutablePointers' is unavailable: use nested withUnsafeMutablePointer(to:_:) instead}} {{none}}
274+
_ = withUnsafePointer(&x) { _ in } // expected-error {{'withUnsafePointer' has been renamed to 'withUnsafePointer(to:_:)'}} {7-24=withUnsafePointer}} {{25-25=to: }} {{none}}
275+
_ = withUnsafePointers(&x, &x) { _, _ in } // expected-error {{'withUnsafePointers' is unavailable: use nested withUnsafePointer(to:_:) instead}} {{none}}
276+
_ = withUnsafePointers(&x, &x, &x) { _, _, _ in } // expected-error {{'withUnsafePointers' is unavailable: use nested withUnsafePointer(to:_:) instead}} {{none}}
277+
}
278+
269279
func _ManagedBuffer<V, E>(x: ManagedBufferPointer<V, E>) {
270280
_ = x.allocatedElementCount // expected-error {{'allocatedElementCount' has been renamed to 'capacity'}} {{9-30=capacity}} {{none}}
271281
}

0 commit comments

Comments
 (0)