Mark SerialExecutor.asUnownedSerialExecutor unsafe so conformances don't need to be @unsafe

What we should actually do with SerialExecutor conformances is not yet clear, though.
This commit is contained in:
Doug Gregor
2024-12-20 23:01:07 -08:00
parent 5b90b8851a
commit 3ab5456eae
2 changed files with 8 additions and 0 deletions

View File

@@ -144,6 +144,7 @@ public protocol SerialExecutor: Executor {
/// Convert this executor value to the optimized form of borrowed
/// executor references.
@unsafe
func asUnownedSerialExecutor() -> UnownedSerialExecutor
/// If this executor has complex equality semantics, and the runtime needs to

View File

@@ -37,3 +37,10 @@ func f() async { // expected-warning{{global function 'f' involves unsafe code;
// expected-warning@+1{{type alias 'WeirdC' involves unsafe code; use '@unsafe' to indicate that its use is not memory-safe}}
typealias WeirdC = RequiresSendable<C> // expected-note{{@unchecked conformance of 'C' to protocol 'Sendable' involves unsafe code}}
@available(SwiftStdlib 5.9, *)
final class MyExecutor: SerialExecutor {
func enqueue(_ job: consuming ExecutorJob) { fatalError("boom") }
@unsafe func asUnownedSerialExecutor() -> UnownedSerialExecutor { fatalError("boom") }
}