Skip to content

Commit c842773

Browse files
committed
[Diagnostics] Re-phrase note about inferred async effect from an operation in a closure body
1 parent 886a8ab commit c842773

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ ERROR(cannot_pass_async_func_to_sync_parameter,none,
563563
"cannot pass function of type %0 "
564564
"to parameter expecting synchronous function type", (Type))
565565

566-
NOTE(async_in_closure_that_does_not_support_concurrency,none,
567-
"'async' in a closure that does not support concurrency", ())
566+
NOTE(async_inferred_from_operation,none,
567+
"'async' inferred from asynchronous operation used here", ())
568568

569569
// Key-path expressions.
570570
ERROR(expr_keypath_no_objc_runtime,none,

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5896,9 +5896,8 @@ bool AsyncFunctionConversionFailure::diagnoseAsError() {
58965896
// 'async' effect is inferred from the body of the closure.
58975897
if (asyncLoc.isInvalid()) {
58985898
if (auto asyncNode = findAsyncNode(closure)) {
5899-
emitDiagnosticAt(
5900-
::getLoc(asyncNode),
5901-
diag::async_in_closure_that_does_not_support_concurrency);
5899+
emitDiagnosticAt(::getLoc(asyncNode),
5900+
diag::async_inferred_from_operation);
59025901
}
59035902
}
59045903
}

test/Concurrency/async_sequence_syntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func missingTryInBlock<T : AsyncSequence>(_ seq: T) {
3535
func missingAsyncInBlock<T : AsyncSequence>(_ seq: T) {
3636
execute { // expected-error{{cannot pass function of type '() async -> Void' to parameter expecting synchronous function type}}
3737
do {
38-
for try await _ in seq { } // expected-note {{'async' in a closure that does not support concurrency}}
38+
for try await _ in seq { } // expected-note {{'async' inferred from asynchronous operation used here}}
3939
} catch { }
4040
}
4141
}

test/Concurrency/async_tasks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func test_unsafeContinuations() async {
4848
// the closure should not allow async operations;
4949
// after all: if you have async code, just call it directly, without the unsafe continuation
5050
let _: String = withUnsafeContinuation { continuation in // expected-error{{cannot pass function of type '(UnsafeContinuation<String, Never>) async -> Void' to parameter expecting synchronous function type}}
51-
let s = await someAsyncFunc() // expected-note {{'async' in a closure that does not support concurrency}}
51+
let s = await someAsyncFunc() // expected-note {{'async' inferred from asynchronous operation used here}}
5252
continuation.resume(returning: s)
5353
}
5454

0 commit comments

Comments
 (0)