You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `voidtake_ptr(const int * __counted_by(len) x __noescape, int len);` | `func take_ptr(_ x: Span<Int32>)` |
498
-
|`const int * __counted_by(len) change_ptr(const int * __counted_by(len) x __lifetimebound, int len);`|`@lifetime(x) func change_ptr(_ x: Span<Int32>) -> Span<Int32>`|
|`void take_ptr_lifetime(const int * __counted_by(len) x __noescape, int len);`|`func take_ptr_lifetime(_ x: Span<Int32>)`|
502
+
|`const int * __counted_by(len) change_ptr_lifetime(const int * __counted_by(len) x __lifetimebound, int len);`|`@lifetime(x) func change_ptr_lifetime(_ x: Span<Int32>) -> Span<Int32>`|
503
+
|`void take_ptr(const int * __counted_by(len) x, int len);`|`func take_ptr(_ x: UnsafeBufferPointer<Int32>)`|
504
+
|`const int * __counted_by(len) change_ptr(const int * __counted_by(len) x, int len);`|`@lifetime(x) func change_ptr(_ x: UnsafeBufferPointer<Int32>) -> UnsafeBufferPointer<Int32>`|
499
505
500
-
These overloads provide the same bounds safety as their `UnsafeBufferPointer` equvalents, but with
501
-
added lifetime safety. If lifetime information is available the generated safe overload will always
506
+
The `UnsafeBufferPointer` overloads provide the same bounds safety as their `Span` equvalents
507
+
(NB: `UnsafeBufferPointer` is not bounds checked on memory access in release builds, but the generated
508
+
`UnsafeBufferPointer` overloads contain bounds checks in the same cases as the `Span` overloads, *even in release builds*),
509
+
but without lifetime safety. If lifetime information is available the generated safe overload will always
502
510
choose to use `Span` - no `UnsafeBufferPointer` overload will be generated in this case. This means
503
511
that existing callers are not affected by annotating an API with `__counted_by`, but callers using the
504
512
safe overload after adding `__counted_by`*will* be affected if `__noescape` is also added later on, or
0 commit comments