Skip to content

Commit 6a5dfb8

Browse files
committed
Mark Task.runDetached as @discardableResult.
Often, this API is used for its side effects and nobody cares about the handle.
1 parent 7fc0b2c commit 6a5dfb8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ extension Task {
377377
/// - Returns: handle to the task, allowing to `await handle.get()` on the
378378
/// tasks result or `cancel` it. If the operation fails the handle will
379379
/// throw the error the operation has thrown when awaited on.
380+
@discardableResult
380381
public static func runDetached<T>(
381382
priority: Priority = .default,
382383
startingOn executor: ExecutorRef? = nil,
@@ -431,6 +432,7 @@ extension Task {
431432
/// - Returns: handle to the task, allowing to `await handle.get()` on the
432433
/// tasks result or `cancel` it. If the operation fails the handle will
433434
/// throw the error the operation has thrown when awaited on.
435+
@discardableResult
434436
public static func runDetached<T, Failure>(
435437
priority: Priority = .default,
436438
startingOn executor: ExecutorRef? = nil,
@@ -458,7 +460,7 @@ extension Task {
458460

459461
public func _runAsyncHandler(operation: @escaping () async -> ()) {
460462
typealias ConcurrentFunctionType = @concurrent () async -> ()
461-
_ = Task.runDetached(
463+
Task.runDetached(
462464
operation: unsafeBitCast(operation, to: ConcurrentFunctionType.self)
463465
)
464466
}
@@ -578,7 +580,7 @@ public func runAsyncAndBlock(_ asyncFun: @escaping () async -> ())
578580
public func _asyncMainDrainQueue() -> Never
579581

580582
public func _runAsyncMain(_ asyncFun: @escaping () async throws -> ()) {
581-
let _ = Task.runDetached {
583+
Task.runDetached {
582584
do {
583585
try await asyncFun()
584586
exit(0)
@@ -680,7 +682,7 @@ internal func _runTaskForBridgedAsyncMethod(_ body: @escaping () async -> Void)
680682
// if we're already running on behalf of a task,
681683
// if the receiver of the method invocation is itself an Actor, or in other
682684
// situations.
683-
_ = Task.runDetached { await body() }
685+
Task.runDetached { await body() }
684686
}
685687

686688
#endif

0 commit comments

Comments
 (0)