Andrew Trick
b5b0c75ccd
Remove diagnostic: lifetime_dependence_on_bitwise_copyable
...
Allow lifetime depenendence on types that are BitwiseCopyable & Escapable.
This is unsafe in the sense that the compiler will not diagnose any use of the
dependent value outside of the lexcial scope of the source value. But, in
practice, dependence on an UnsafePointer is often needed. In that case, the
programmer should have already taken responsibility for ensuring the lifetime of the
pointer over all dependent uses. Typically, an unsafe pointer is valid for the
duration of a closure. Lifetime dependence prevents the dependent value from
being returned by the closure, so common usage is safe by default.
Typical example:
func decode(_ bufferRef: Span<Int>) { /*...*/ }
extension UnsafeBufferPointer {
// The client must ensure the lifetime of the buffer across the invocation of `body`.
// The client must ensure that no code modifies the buffer during the invocation of `body`.
func withUnsafeSpan<Result>(_ body: (Span<Element>) throws -> Result) rethrows -> Result {
// Construct Span using its internal, unsafe API.
try body(Span(unsafePointer: baseAddress!, count: count))
}
}
func decodeArrayAsUBP(array: [Int]) {
array.withUnsafeBufferPointer { buffer in
buffer.withUnsafeSpan {
decode($0)
}
}
}
In the future, we may add SILGen support for tracking the lexical scope of
BitwiseCopyable values. That would allow them to have the same dependence
behavior as other source values.
2024-05-22 17:10:56 -07:00
..
2024-05-22 17:10:56 -07:00
2024-02-19 02:48:36 -10:00
2023-11-28 13:16:32 -08:00
2024-03-18 12:32:33 -07:00
2022-05-10 12:56:17 -04:00
2024-04-19 12:19:29 -07:00
2024-04-10 09:38:02 -07:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2021-10-28 14:36:36 -07:00
2023-03-02 10:09:29 -08:00
2023-08-16 20:57:50 -07:00
2022-08-04 14:19:33 -07:00
2023-01-23 17:52:37 -08:00
2023-01-23 17:52:37 -08:00
2023-05-03 14:33:19 -07:00
2024-02-28 08:37:44 -08:00
2024-02-29 10:09:08 -08:00
2024-03-11 14:28:20 -07:00
2024-02-29 11:49:26 -08:00
2022-05-09 10:08:52 -07:00
2023-01-23 18:33:25 -08:00
2022-04-15 20:13:00 -07:00
2023-05-30 13:33:26 -07:00
2023-05-30 13:33:26 -07:00
2022-04-15 20:12:59 -07:00
2022-04-15 20:12:59 -07:00
2023-05-08 13:56:52 -07:00
2022-09-01 06:41:44 +03:00
2024-05-08 16:53:14 -07:00
2024-05-08 16:53:14 -07:00
2023-10-28 14:38:11 -07:00
2023-07-12 13:53:36 -07:00
2021-05-18 13:21:31 -07:00
2021-08-27 14:50:56 -07:00
2021-05-14 13:04:44 -07:00
2024-04-05 07:52:14 -07:00
2024-04-05 07:52:14 -07:00
2023-08-09 14:24:11 -07:00
2024-02-20 07:27:39 -08:00
2022-04-14 15:09:36 -07:00
2022-12-21 08:52:53 +01:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2023-09-21 00:55:17 -07:00
2022-09-01 06:41:44 +03:00
2022-11-08 18:35:27 -08:00
2021-08-18 16:22:26 -04:00
2021-07-19 14:14:59 -07:00
2024-04-19 11:34:01 -07:00
2023-12-13 10:53:42 +09:00
2024-04-10 09:38:02 -07:00
2023-09-19 10:38:42 -07:00
2021-11-09 15:58:42 -08:00
2024-02-14 21:53:54 -08:00
2023-09-15 13:16:46 -07:00
2022-04-15 20:13:00 -07:00
2023-02-16 15:23:45 -08:00
2023-06-20 13:15:09 -07:00
2022-04-15 20:12:59 -07:00
2023-04-07 21:23:27 -07:00
2022-05-23 19:43:51 -07:00
2024-03-28 14:48:15 -07:00
2022-08-16 08:36:58 -07:00
2023-10-02 10:42:00 -07:00
2023-10-16 22:05:26 -07:00
2022-02-19 10:32:29 -07:00
2022-04-15 20:13:00 -07:00
2024-04-05 07:52:14 -07:00
2024-01-11 13:54:24 -08:00
2023-05-10 18:19:49 -07:00
2024-05-08 15:48:54 -07:00
2021-06-11 20:04:43 -07:00
2022-04-14 15:09:36 -07:00
2022-10-03 17:22:44 -07:00
2022-04-15 20:13:00 -07:00
2023-10-25 14:57:22 -06:00
2021-05-21 14:52:10 -07:00
2023-06-12 16:53:48 -07:00
2023-02-15 10:06:39 -08:00
2024-03-01 12:05:51 -08:00
2022-06-12 20:25:16 -07:00
2024-04-19 12:19:29 -07:00
2023-09-18 10:54:35 -07:00
2022-04-15 20:13:00 -07:00
2024-04-05 07:52:14 -07:00
2022-04-15 20:13:00 -07:00
2022-12-19 09:50:08 -08:00
2024-01-03 19:36:16 -08:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2024-05-08 10:49:12 -07:00
2024-05-08 10:49:12 -07:00
2024-03-27 22:20:50 -07:00
2023-03-28 22:43:45 -07:00
2023-11-03 09:37:24 -07:00
2023-10-31 16:48:04 -07:00
2024-05-08 10:49:12 -07:00
2024-03-12 01:39:50 -07:00
2024-02-19 02:48:36 -10:00
2023-12-10 10:10:15 -08:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2024-04-22 13:08:20 -07:00
2022-11-04 11:10:59 -07:00
2023-05-30 09:54:31 +01:00
2023-10-19 11:46:08 -07:00
2022-04-15 20:13:00 -07:00
2023-12-08 22:33:12 -08:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2024-05-13 10:43:25 -07:00
2024-05-21 12:42:54 -07:00
2022-04-15 20:13:00 -07:00
2022-01-20 14:48:55 -08:00
2024-04-30 12:03:46 -07:00
2022-09-01 06:41:44 +03:00
2024-04-09 13:32:03 -07:00
2022-04-15 20:13:00 -07:00
2021-10-29 22:35:57 +02:00
2023-08-16 20:57:50 -07:00
2023-08-16 20:57:50 -07:00
2022-06-02 18:15:31 -04:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2023-07-12 12:34:37 -04:00
2023-12-06 14:27:33 -08:00
2024-02-21 16:28:19 -08:00
2022-11-07 18:38:06 -05:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:13:00 -07:00
2024-04-14 21:28:13 -07:00
2024-02-27 10:26:31 -08:00
2024-01-03 15:33:33 -08:00
2022-04-15 20:12:59 -07:00
2023-06-20 13:15:09 -07:00
2024-03-05 13:24:31 -08:00
2022-04-15 20:13:00 -07:00
2024-03-07 17:30:17 -05:00
2022-04-15 20:13:00 -07:00
2022-08-16 18:31:13 -07:00
2022-04-18 09:12:35 -07:00
2023-08-28 08:28:56 -07:00
2024-03-18 12:32:33 -07:00
2024-03-26 17:27:57 -07:00
2022-07-06 22:16:16 -07:00
2022-04-15 20:13:00 -07:00
2023-02-22 12:53:10 -08:00
2022-04-15 20:13:00 -07:00
2022-04-15 20:12:59 -07:00
2022-04-15 20:12:59 -07:00
2022-08-31 23:55:29 -07:00
2022-04-15 20:13:00 -07:00
2022-06-30 17:25:17 -07:00
2022-04-15 20:13:00 -07:00
2023-03-29 14:45:22 -07:00
2022-04-15 20:13:00 -07:00
2022-07-14 15:04:27 -07:00
2022-04-15 20:13:00 -07:00
2023-10-03 13:24:39 -07:00
2023-11-01 15:55:19 -07:00
2022-04-15 20:13:00 -07:00
2024-01-04 10:39:39 -08:00
2023-10-16 22:05:26 -07:00
2022-05-31 08:24:49 -07:00
2022-05-09 14:10:07 -07:00
2022-04-15 20:13:00 -07:00
2024-02-21 17:59:49 -08:00
2024-02-19 02:48:36 -10:00
2021-05-18 11:04:04 -07:00
2024-02-19 17:47:16 -08:00
2023-01-02 21:22:04 -08:00
2024-02-08 14:29:05 -07:00
2022-08-11 11:02:57 -07:00
2021-06-11 20:04:43 -07:00