Skip to content

Commit c193757

Browse files
authored
Merge pull request swiftlang#35977 from DougGregor/discardable-run-detached
2 parents 77d828d + 6a5dfb8 commit c193757

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
@@ -392,6 +392,7 @@ extension Task {
392392
/// - Returns: handle to the task, allowing to `await handle.get()` on the
393393
/// tasks result or `cancel` it. If the operation fails the handle will
394394
/// throw the error the operation has thrown when awaited on.
395+
@discardableResult
395396
public static func runDetached<T>(
396397
priority: Priority = .default,
397398
startingOn executor: ExecutorRef? = nil,
@@ -447,6 +448,7 @@ extension Task {
447448
/// - Returns: handle to the task, allowing to `await handle.get()` on the
448449
/// tasks result or `cancel` it. If the operation fails the handle will
449450
/// throw the error the operation has thrown when awaited on.
451+
@discardableResult
450452
public static func runDetached<T, Failure>(
451453
priority: Priority = .default,
452454
startingOn executor: ExecutorRef? = nil,
@@ -474,7 +476,7 @@ extension Task {
474476

475477
public func _runAsyncHandler(operation: @escaping () async -> ()) {
476478
typealias ConcurrentFunctionType = @concurrent () async -> ()
477-
_ = Task.runDetached(
479+
Task.runDetached(
478480
operation: unsafeBitCast(operation, to: ConcurrentFunctionType.self)
479481
)
480482
}
@@ -594,7 +596,7 @@ public func runAsyncAndBlock(_ asyncFun: @escaping () async -> ())
594596
public func _asyncMainDrainQueue() -> Never
595597

596598
public func _runAsyncMain(_ asyncFun: @escaping () async throws -> ()) {
597-
let _ = Task.runDetached {
599+
Task.runDetached {
598600
do {
599601
try await asyncFun()
600602
exit(0)
@@ -704,7 +706,7 @@ internal func _runTaskForBridgedAsyncMethod(_ body: @escaping () async -> Void)
704706
// if we're already running on behalf of a task,
705707
// if the receiver of the method invocation is itself an Actor, or in other
706708
// situations.
707-
_ = Task.runDetached { await body() }
709+
Task.runDetached { await body() }
708710
}
709711

710712
#endif

0 commit comments

Comments
 (0)