Skip to content

Commit 699692b

Browse files
committed
[region-isolation] Change diagnostics from using the term transferring -> sending.
rdar://127580781
1 parent ef5aae1 commit 699692b

28 files changed

+715
-715
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,10 @@ ERROR(regionbasedisolation_unknown_pattern, none,
953953
//
954954

955955
ERROR(regionbasedisolation_transfer_yields_race_no_isolation, none,
956-
"transferring value of non-Sendable type %0; later accesses could race",
956+
"sending value of non-Sendable type %0; later accesses could race",
957957
(Type))
958958
ERROR(regionbasedisolation_transfer_yields_race_with_isolation, none,
959-
"transferring value of non-Sendable type %0 from %1 context to %2 context; later accesses could race",
959+
"sending value of non-Sendable type %0 from %1 context to %2 context; later accesses could race",
960960
(Type, ActorIsolation, ActorIsolation))
961961
ERROR(regionbasedisolation_isolated_capture_yields_race, none,
962962
"%1 closure captures value of non-Sendable type %0 from %2 context; later accesses to value could race",
@@ -965,7 +965,7 @@ ERROR(regionbasedisolation_transfer_yields_race_stronglytransferred_binding, non
965965
"value of non-Sendable type %0 accessed after being transferred; later accesses could race",
966966
(Type))
967967
ERROR(regionbasedisolation_arg_transferred, none,
968-
"%0 value of type %1 transferred to %2 context; later accesses to value could race",
968+
"sending %0 value of type %1 to %2 context; later accesses to value could race",
969969
(StringRef, Type, ActorIsolation))
970970
ERROR(regionbasedisolation_arg_passed_to_strongly_transferred_param, none,
971971
"%0 value of type %1 passed as a strongly transferred parameter; later accesses could race",
@@ -979,14 +979,14 @@ NOTE(regionbasedisolation_isolated_since_in_same_region_basename, none,
979979
//
980980

981981
ERROR(regionbasedisolation_named_transfer_yields_race, none,
982-
"transferring %0 may cause a data race",
982+
"sending %0 may cause a data race",
983983
(Identifier))
984984

985985
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
986-
"transferring %1 %0 to %2 callee could cause races in between callee %2 and local %3 uses",
986+
"sending %1 %0 to %2 callee could cause races in between callee %2 and local %3 uses",
987987
(Identifier, StringRef, ActorIsolation, ActorIsolation))
988988
NOTE(regionbasedisolation_named_transfer_non_transferrable, none,
989-
"transferring %1 %0 to %2 callee could cause races between %2 and %1 uses",
989+
"sending %1 %0 to %2 callee could cause races between %2 and %1 uses",
990990
(Identifier, StringRef, ActorIsolation))
991991
NOTE(regionbasedisolation_named_transfer_into_transferring_param, none,
992992
"%0 %1 is passed as a transferring parameter; Uses in callee may race with later %0 uses",
@@ -1003,7 +1003,7 @@ NOTE(regionbasedisolation_named_isolated_closure_yields_race, none,
10031003

10041004
// Misc Error.
10051005
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
1006-
"task or actor isolated value cannot be transferred", ())
1006+
"task or actor isolated value cannot be sent", ())
10071007

10081008
// TODO: print the name of the nominal type
10091009
ERROR(deinit_not_visible, none,

test/ClangImporter/transferring.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ func funcTestTransferringResult() async {
2727
// Just to show that without the transferring param, we generate diagnostics.
2828
let x2 = NonSendableCStruct()
2929
let y2 = returnUserDefinedFromGlobalFunction(x2)
30-
await transferToMain(x2) // expected-error {{transferring 'x2' may cause a data race}}
31-
// expected-note @-1 {{transferring disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
30+
await transferToMain(x2) // expected-error {{sending 'x2' may cause a data race}}
31+
// expected-note @-1 {{sending disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
3232
useValue(y2) // expected-note {{use here could race}}
3333
}
3434

3535
func funcTestTransferringArg() async {
3636
let x = NonSendableCStruct()
37-
transferUserDefinedIntoGlobalFunction(x) // expected-error {{transferring 'x' may cause a data race}}
37+
transferUserDefinedIntoGlobalFunction(x) // expected-error {{sending 'x' may cause a data race}}
3838
// expected-note @-1 {{'x' used after being passed as a transferring parameter}}
3939
useValue(x) // expected-note {{use here could race}}
4040
}

test/ClangImporter/transferring_objc.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func methodTestTransferringResult() async {
2525
func methodTestTransferringArg() async {
2626
let x = MyType()
2727
let s = NSObject()
28-
let _ = x.getResultWithTransferringArgument(s) // expected-error {{transferring 's' may cause a data race}}
28+
let _ = x.getResultWithTransferringArgument(s) // expected-error {{sending 's' may cause a data race}}
2929
// expected-note @-1 {{'s' used after being passed as a transferring parameter; Later uses could race}}
3030
useValue(s) // expected-note {{use here could race}}
3131
}
@@ -45,14 +45,14 @@ func funcTestTransferringResult() async {
4545
// Just to show that without the transferring param, we generate diagnostics.
4646
let x2 = NSObject()
4747
let y2 = returnNSObjectFromGlobalFunction(x2)
48-
await transferToMain(x2) // expected-error {{transferring 'x2' may cause a data race}}
49-
// expected-note @-1 {{transferring disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
48+
await transferToMain(x2) // expected-error {{sending 'x2' may cause a data race}}
49+
// expected-note @-1 {{sending disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
5050
useValue(y2) // expected-note {{use here could race}}
5151
}
5252

5353
func funcTestTransferringArg() async {
5454
let x = NSObject()
55-
transferNSObjectToGlobalFunction(x) // expected-error {{transferring 'x' may cause a data race}}
55+
transferNSObjectToGlobalFunction(x) // expected-error {{sending 'x' may cause a data race}}
5656
// expected-note @-1 {{'x' used after being passed as a transferring parameter; Later uses could race}}
5757
useValue(x) // expected-note {{use here could race}}
5858
}

test/Concurrency/isolated_captures.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NotSendable {
4040
MyActor.ns = ns
4141

4242
await { @YourActor in
43-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
43+
// expected-region-isolation-warning @+3 {{sending 'ns' may cause a data race}}
4444
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
4545
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
4646
YourActor.ns = ns
@@ -62,7 +62,7 @@ class NotSendable {
6262
ns.stash()
6363

6464
await { @YourActor in
65-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
65+
// expected-region-isolation-warning @+3 {{sending 'ns' may cause a data race}}
6666
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
6767
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
6868
YourActor.ns = ns
@@ -83,7 +83,7 @@ class NotSendable {
8383
let ns = NotSendable()
8484

8585
await { @YourActor in
86-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
86+
// expected-region-isolation-warning @+3 {{sending 'ns' may cause a data race}}
8787
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
8888
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
8989
YourActor.ns = ns

test/Concurrency/issue-57376.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,45 @@ func testAsyncSequence1Sendable<Seq: AsyncSequence>(_ seq: Seq) async throws whe
3434

3535
func testAsyncSequenceTypedPattern<Seq: AsyncSequence>(_ seq: Seq) async throws where Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{54-54=, Sendable}}
3636
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{54-54=, Sendable}}
37-
async let result: Int = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
37+
async let result: Int = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
3838
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
3939
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
4040
let _ = try! await result
4141
}
4242

4343
func testAsyncSequenceTypedPattern1<Seq: AsyncSequence>(_ seq: Seq) async throws where Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{55-55=, Sendable}}
4444
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{55-55=, Sendable}}
45-
async let _: Int = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
45+
async let _: Int = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
4646
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
4747
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
4848
}
4949

5050
func testAsyncSequence<Seq: AsyncSequence>(_ seq: Seq) async throws where Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{42-42=, Sendable}}
5151
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{42-42=, Sendable}}
52-
async let result = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
52+
async let result = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
5353
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
5454
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
5555
let _ = try! await result
5656
}
5757

5858
func testAsyncSequence1<Seq: AsyncSequence>(_ seq: Seq) async throws where Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{43-43=, Sendable}}
5959
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{43-43=, Sendable}}
60-
async let _ = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
60+
async let _ = seq.reduce(0) { $0 + $1 } // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
6161
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
6262
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
6363
}
6464

6565
func testAsyncSequence3<Seq>(_ seq: Seq) async throws where Seq: AsyncSequence, Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
6666
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
67-
async let result = seq // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
67+
async let result = seq // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
6868
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
6969
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
7070
let _ = await result
7171
}
7272

7373
func testAsyncSequence4<Seq>(_ seq: Seq) async throws where Seq: AsyncSequence, Seq.Element == Int { // expected-targeted-and-complete-note {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
7474
// expected-no-transferring-tns-note @-1 {{consider making generic parameter 'Seq' conform to the 'Sendable' protocol}} {{28-28=: Sendable}}
75-
async let _ = seq // expected-transferring-tns-warning {{task or actor isolated value cannot be transferred}}
75+
async let _ = seq // expected-transferring-tns-warning {{task or actor isolated value cannot be sent}}
7676
// expected-targeted-and-complete-warning @-1 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
7777
// expected-no-transferring-tns-warning @-2 {{capture of 'seq' with non-sendable type 'Seq' in 'async let' binding}}
7878
}

test/Concurrency/sendable_checking.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public actor MyActor: MyProto {
9696

9797
func g(ns1: NS1) async {
9898
await nonisolatedAsyncFunc1(ns1) // expected-targeted-and-complete-warning{{passing argument of non-sendable type 'NS1' outside of actor-isolated context may introduce data races}}
99-
// expected-tns-warning @-1 {{transferring 'ns1' may cause a data race}}
100-
// expected-tns-note @-2 {{transferring actor-isolated 'ns1' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
99+
// expected-tns-warning @-1 {{sending 'ns1' may cause a data race}}
100+
// expected-tns-note @-2 {{sending actor-isolated 'ns1' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
101101
_ = await nonisolatedAsyncFunc2() // expected-warning{{non-sendable type 'NS1' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary}}
102102
}
103103
}
@@ -253,13 +253,13 @@ final class NonSendable {
253253
func call() async {
254254
await update()
255255
// expected-targeted-and-complete-warning @-1 {{passing argument of non-sendable type 'NonSendable' into main actor-isolated context may introduce data races}}
256-
// expected-tns-warning @-2 {{transferring 'self' may cause a data race}}
257-
// expected-tns-note @-3 {{transferring task-isolated 'self' to main actor-isolated callee could cause races between main actor-isolated and task-isolated uses}}
256+
// expected-tns-warning @-2 {{sending 'self' may cause a data race}}
257+
// expected-tns-note @-3 {{sending task-isolated 'self' to main actor-isolated callee could cause races between main actor-isolated and task-isolated uses}}
258258

259259
await self.update()
260260
// expected-targeted-and-complete-warning @-1 {{passing argument of non-sendable type 'NonSendable' into main actor-isolated context may introduce data races}}
261-
// expected-tns-warning @-2 {{transferring 'self' may cause a data race}}
262-
// expected-tns-note @-3 {{transferring task-isolated 'self' to main actor-isolated callee could cause races between main actor-isolated and task-isolated uses}}
261+
// expected-tns-warning @-2 {{sending 'self' may cause a data race}}
262+
// expected-tns-note @-3 {{sending task-isolated 'self' to main actor-isolated callee could cause races between main actor-isolated and task-isolated uses}}
263263

264264
_ = await x
265265
// expected-warning@-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}}
@@ -277,8 +277,8 @@ func testNonSendableBaseArg() async {
277277
let t = NonSendable()
278278
await t.update()
279279
// expected-targeted-and-complete-warning @-1 {{passing argument of non-sendable type 'NonSendable' into main actor-isolated context may introduce data races}}
280-
// expected-tns-warning @-2 {{transferring 't' may cause a data race}}
281-
// expected-tns-note @-3 {{transferring disconnected 't' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
280+
// expected-tns-warning @-2 {{sending 't' may cause a data race}}
281+
// expected-tns-note @-3 {{sending disconnected 't' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
282282

283283
_ = await t.x
284284
// expected-warning @-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}}
@@ -297,14 +297,14 @@ func callNonisolatedAsyncClosure(
297297
) async {
298298
await g(ns)
299299
// expected-targeted-and-complete-warning @-1 {{passing argument of non-sendable type 'NonSendable' outside of main actor-isolated context may introduce data races}}
300-
// expected-tns-warning @-2 {{transferring 'ns' may cause a data race}}
301-
// expected-tns-note @-3 {{transferring main actor-isolated 'ns' to nonisolated callee could cause races between nonisolated and main actor-isolated uses}}
300+
// expected-tns-warning @-2 {{sending 'ns' may cause a data race}}
301+
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to nonisolated callee could cause races between nonisolated and main actor-isolated uses}}
302302

303303
let f: (NonSendable) async -> () = globalSendable // okay
304304
await f(ns)
305305
// expected-targeted-and-complete-warning@-1 {{passing argument of non-sendable type 'NonSendable' outside of main actor-isolated context may introduce data races}}
306-
// expected-tns-warning @-2 {{transferring 'ns' may cause a data race}}
307-
// expected-tns-note @-3 {{transferring main actor-isolated 'ns' to nonisolated callee could cause races between nonisolated and main actor-isolated uses}}
306+
// expected-tns-warning @-2 {{sending 'ns' may cause a data race}}
307+
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to nonisolated callee could cause races between nonisolated and main actor-isolated uses}}
308308
}
309309

310310
@available(SwiftStdlib 5.1, *)

0 commit comments

Comments
 (0)