Skip to content

Commit 177dad4

Browse files
committed
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.
1 parent 8d76edf commit 177dad4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stdlib/public/Concurrency/Executor.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public protocol SerialExecutor: Executor {
144144

145145
/// Convert this executor value to the optimized form of borrowed
146146
/// executor references.
147+
@unsafe
147148
func asUnownedSerialExecutor() -> UnownedSerialExecutor
148149

149150
/// If this executor has complex equality semantics, and the runtime needs to

test/Unsafe/unsafe_concurrency.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ func f() async { // expected-warning{{global function 'f' involves unsafe code;
3737

3838
// expected-warning@+1{{type alias 'WeirdC' involves unsafe code; use '@unsafe' to indicate that its use is not memory-safe}}
3939
typealias WeirdC = RequiresSendable<C> // expected-note{{@unchecked conformance of 'C' to protocol 'Sendable' involves unsafe code}}
40+
41+
42+
@available(SwiftStdlib 5.9, *)
43+
final class MyExecutor: SerialExecutor {
44+
func enqueue(_ job: consuming ExecutorJob) { fatalError("boom") }
45+
@unsafe func asUnownedSerialExecutor() -> UnownedSerialExecutor { fatalError("boom") }
46+
}

0 commit comments

Comments
 (0)