Skip to content

Commit 6de44f4

Browse files
committed
[rbi] Convert mutable box sending closure diagnostic to use modifiable instead of accessible in error message.
This emphasizes that the problem is that the mutable value could be modified in multiple isolation domains which is clearer to the user. I came up with this diagnostic in the previous commit for isolated partial applies, so it makes sense to also be consistent with sending closures.
1 parent 230a3a9 commit 6de44f4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_
10981098
"closure captures %0 which is accessible to code in the current task",
10991099
(DeclName))
11001100
NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_boxed_value_task_isolated, none,
1101-
"closure captures reference to mutable %kind0 which is accessible to code in the current task",
1101+
"closure captures reference to mutable %kind0 which remains modifiable by code in the current task",
11021102
(const ValueDecl *))
11031103
NOTE(regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_value_region, none,
11041104
"closure captures %1 which is accessible to %0 code",

test/Concurrency/transfernonsendable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ extension MyActor {
17941794
func nonSendableAllocBoxConsumingParameter(x: consuming SendableKlass) async throws {
17951795
try await withThrowingTaskGroup(of: Void.self) { group in
17961796
group.addTask { // expected-warning {{passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure}}
1797-
useValue(x) // expected-note {{closure captures reference to mutable parameter 'x' which is accessible to code in the current task}}
1797+
useValue(x) // expected-note {{closure captures reference to mutable parameter 'x' which remains modifiable by code in the current task}}
17981798
}
17991799

18001800
try await group.waitForAll()
@@ -1807,7 +1807,7 @@ func nonSendableAllocBoxConsumingVar() async throws {
18071807

18081808
try await withThrowingTaskGroup(of: Void.self) { group in
18091809
group.addTask { // expected-warning {{passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure}}
1810-
useValue(x) // expected-note {{closure captures reference to mutable var 'x' which is accessible to code in the current task}}
1810+
useValue(x) // expected-note {{closure captures reference to mutable var 'x' which remains modifiable by code in the current task}}
18111811
}
18121812

18131813
try await group.waitForAll()
@@ -1865,7 +1865,7 @@ func testFunctionIsNotEmpty(input: SendableKlass) async throws {
18651865
var result: [SendableKlass] = []
18661866
try await withThrowingTaskGroup(of: Void.self) { taskGroup in // expected-warning {{no calls to throwing functions occur within 'try' expression}}
18671867
taskGroup.addTask { // expected-warning {{passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure}}
1868-
result.append(input) // expected-note {{closure captures reference to mutable var 'result' which is accessible to code in the current task}}
1868+
result.append(input) // expected-note {{closure captures reference to mutable var 'result' which remains modifiable by code in the current task}}
18691869
}
18701870
}
18711871
}

0 commit comments

Comments
 (0)