Skip to content

Commit a5c8106

Browse files
committed
[region-isolation] Standardize on task-isolated instead of task isolated.
This matches actor-isolated as used in other parts of the compiler.
1 parent b2c85a8 commit a5c8106

12 files changed

+59
-59
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,10 @@ ERROR(regionbasedisolation_transfer_yields_race_stronglytransferred_binding, non
954954
"binding of non-Sendable type %0 accessed after being transferred; later accesses could race",
955955
(Type))
956956
ERROR(regionbasedisolation_arg_transferred, none,
957-
"task isolated value of type %0 transferred to %1 context; later accesses to value could race",
957+
"task-isolated value of type %0 transferred to %1 context; later accesses to value could race",
958958
(Type, ActorIsolation))
959959
ERROR(regionbasedisolation_arg_passed_to_strongly_transferred_param, none,
960-
"task isolated value of type %0 passed as a strongly transferred parameter; later accesses could race",
960+
"task-isolated value of type %0 passed as a strongly transferred parameter; later accesses could race",
961961
(Type))
962962
NOTE(regionbasedisolation_isolated_since_in_same_region_basename, none,
963963
"value is %0 since it is in the same region as %1",
@@ -974,7 +974,7 @@ ERROR(regionbasedisolation_stronglytransfer_assignment_yields_race_name, none,
974974
"assigning %0 to transferring parameter %1 may cause a race",
975975
(Identifier, Identifier))
976976
NOTE(regionbasedisolation_stronglytransfer_taskisolated_assign_note, none,
977-
"%0 is a task isolated value that is assigned into transferring parameter %1. Transferred uses of %1 may race with caller uses of %0",
977+
"%0 is a task-isolated value that is assigned into transferring parameter %1. Transferred uses of %1 may race with caller uses of %0",
978978
(Identifier, Identifier))
979979

980980
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
@@ -987,7 +987,7 @@ NOTE(regionbasedisolation_named_info_isolated_capture, none,
987987
"%1 value %0 is captured by %2 closure. Later local uses could race",
988988
(Identifier, ActorIsolation, ActorIsolation))
989989
NOTE(regionbasedisolation_named_arg_info, none,
990-
"Transferring task isolated function argument %0 could yield races with caller uses",
990+
"Transferring task-isolated function argument %0 could yield races with caller uses",
991991
(Identifier))
992992
NOTE(regionbasedisolation_named_stronglytransferred_binding, none,
993993
"Cannot access a transferring parameter after the parameter has been transferred", ())

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ class TransferNonTransferrableDiagnosticEmitter {
909909
diagnoseNote(
910910
fArg->getDecl()->getLoc(),
911911
diag::regionbasedisolation_isolated_since_in_same_region_basename,
912-
"task isolated", fArg->getDecl()->getBaseName());
912+
"task-isolated", fArg->getDecl()->getBaseName());
913913
}
914914
}
915915
}
@@ -930,7 +930,7 @@ class TransferNonTransferrableDiagnosticEmitter {
930930
diagnoseNote(
931931
fArg->getDecl()->getLoc(),
932932
diag::regionbasedisolation_isolated_since_in_same_region_basename,
933-
"task isolated", fArg->getDecl()->getBaseName());
933+
"task-isolated", fArg->getDecl()->getBaseName());
934934
}
935935

936936
void emitFunctionArgumentApplyStronglyTransferred(SILLocation loc,

test/Concurrency/transfernonsendable.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ bb0(%0 : $*{ var NonSendableKlass }):
108108

109109
%f = function_ref @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
110110
apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %f<NonSendableKlass>(%3) : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
111-
// expected-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to global actor '<null>'-isolated context}}
111+
// expected-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to global actor '<null>'-isolated context}}
112112
destroy_value %1 : ${ var NonSendableKlass }
113113

114114
%9999 = tuple ()
@@ -282,7 +282,7 @@ bb0(%0 : @guaranteed $MyActor):
282282
%3 = class_method %0 : $MyActor, #MyActor.klass!getter : (isolated MyActor) -> () -> NonSendableKlass, $@convention(method) (@sil_isolated @guaranteed MyActor) -> @owned NonSendableKlass
283283
%4 = apply %3(%0) : $@convention(method) (@sil_isolated @guaranteed MyActor) -> @owned NonSendableKlass
284284
%5 = class_method %4 : $NonSendableKlass, #NonSendableKlass.asyncCall : (NonSendableKlass) -> () async -> (), $@convention(method) @async (@guaranteed NonSendableKlass) -> ()
285-
%6 = apply [caller_isolation=nonisolated] [callee_isolation=actor_instance] %5(%4) : $@convention(method) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{task isolated value of type 'NonSendableKlass' transferred to actor-isolated context; later accesses to value could race}}
285+
%6 = apply [caller_isolation=nonisolated] [callee_isolation=actor_instance] %5(%4) : $@convention(method) @async (@guaranteed NonSendableKlass) -> () // expected-warning {{task-isolated value of type 'NonSendableKlass' transferred to actor-isolated context; later accesses to value could race}}
286286
destroy_value %4 : $NonSendableKlass
287287
hop_to_executor %0 : $MyActor
288288
%9 = tuple ()

test/Concurrency/transfernonsendable.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,25 +213,25 @@ extension Actor {
213213
// expected-tns-note @-3 {{transferring actor-isolated 'closure' to main actor-isolated callee could cause races between main actor-isolated and actor-isolated uses}}
214214
}
215215

216-
// TODO: Why is this task isolated?
216+
// TODO: Why is this task-isolated?
217217
func simpleClosureCaptureSelfAndTransferThroughTuple() async {
218218
let closure: () -> () = {
219219
print(self.klass)
220220
}
221221
let x = (1, closure)
222222
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type '(Int, () -> ())' into main actor-isolated context may introduce data races}}
223223
// expected-complete-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
224-
// expected-tns-warning @-2 {{task isolated value of type '(Int, () -> ())' transferred to main actor-isolated context}}
224+
// expected-tns-warning @-2 {{task-isolated value of type '(Int, () -> ())' transferred to main actor-isolated context}}
225225
}
226226

227-
// TODO: Why is this task isolated?
227+
// TODO: Why is this task-isolated?
228228
func simpleClosureCaptureSelfAndTransferThroughTupleBackwards() async {
229229
let closure: () -> () = {
230230
print(self.klass)
231231
}
232232

233233
let x = (closure, 1)
234-
await transferToMain(x) // expected-tns-warning {{task isolated value of type '(() -> (), Int)' transferred to main actor-isolated context}}
234+
await transferToMain(x) // expected-tns-warning {{task-isolated value of type '(() -> (), Int)' transferred to main actor-isolated context}}
235235
// expected-complete-warning @-1 {{passing argument of non-sendable type '(() -> (), Int)' into main actor-isolated context may introduce data races}}
236236
// expected-complete-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
237237
}
@@ -1366,26 +1366,26 @@ actor ActorWithSetter {
13661366
var recursive: ActorWithSetter? = nil
13671367
var classBox = TwoFieldKlassClassBox()
13681368

1369-
// TODO: Why is this task isolated? This should be actor isolated?
1369+
// TODO: Why is this task-isolated? This should be actor isolated?
13701370
func test1() async {
13711371
let x = NonSendableKlass()
13721372
self.field = x
13731373
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1374-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1374+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
13751375
}
13761376

13771377
func test2() async {
13781378
let x = NonSendableKlass()
13791379
self.twoFieldBox.k1 = x
13801380
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1381-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1381+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
13821382
}
13831383

13841384
func test3() async {
13851385
let x = NonSendableKlass()
13861386
self.twoFieldBoxInTuple.1.k1 = x
13871387
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1388-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1388+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
13891389
}
13901390

13911391
// This triggers a crash in SILGen with tns enabled.
@@ -1405,7 +1405,7 @@ actor ActorWithSetter {
14051405
let x = NonSendableKlass()
14061406
self.classBox.k1 = x
14071407
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1408-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1408+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
14091409
}
14101410
}
14111411

@@ -1420,21 +1420,21 @@ final actor FinalActorWithSetter {
14201420
let x = NonSendableKlass()
14211421
self.field = x
14221422
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1423-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1423+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
14241424
}
14251425

14261426
func test2() async {
14271427
let x = NonSendableKlass()
14281428
self.twoFieldBox.k1 = x
14291429
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1430-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1430+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
14311431
}
14321432

14331433
func test3() async {
14341434
let x = NonSendableKlass()
14351435
self.twoFieldBoxInTuple.1.k1 = x
14361436
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1437-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1437+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
14381438
}
14391439

14401440
// This triggers a crash in SILGen with tns enabled.
@@ -1454,12 +1454,12 @@ final actor FinalActorWithSetter {
14541454
let x = NonSendableKlass()
14551455
self.classBox.k1 = x
14561456
await transferToMain(x) // expected-complete-warning {{passing argument of non-sendable type 'NonSendableKlass' into main actor-isolated context may introduce data races}}
1457-
// expected-tns-warning @-1 {{task isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
1457+
// expected-tns-warning @-1 {{task-isolated value of type 'NonSendableKlass' transferred to main actor-isolated context}}
14581458
}
14591459
}
14601460

14611461
func functionArgumentIntoClosure(_ x: @escaping () -> ()) async {
14621462
let _ = { @MainActor in
1463-
let _ = x // expected-tns-warning {{task isolated value of type '() -> ()' transferred to main actor-isolated context}}
1463+
let _ = x // expected-tns-warning {{task-isolated value of type '() -> ()' transferred to main actor-isolated context}}
14641464
}
14651465
}

test/Concurrency/transfernonsendable_global_actor.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ private class NonSendableLinkedListNode<T> { // expected-complete-note 3{{}}
4949
let x = firstList
5050

5151
// TODO: This should say global actor isolated isolated.
52-
await transferToMainActor(x) // expected-tns-warning {{task isolated value of type 'NonSendableLinkedList<Int>' transferred to main actor-isolated context}}
52+
await transferToMainActor(x) // expected-tns-warning {{task-isolated value of type 'NonSendableLinkedList<Int>' transferred to main actor-isolated context}}
5353
// expected-complete-warning @-1 {{passing argument of non-sendable type 'NonSendableLinkedList<Int>' into main actor-isolated context may introduce data races}}
5454

5555
let y = secondList.listHead!.next!
5656

57-
await transferToMainActor(y) // expected-tns-warning {{task isolated value of type 'NonSendableLinkedListNode<Int>' transferred to main actor-isolated context}}
57+
await transferToMainActor(y) // expected-tns-warning {{task-isolated value of type 'NonSendableLinkedListNode<Int>' transferred to main actor-isolated context}}
5858
// expected-complete-warning @-1 {{passing argument of non-sendable type 'NonSendableLinkedListNode<Int>' into main actor-isolated context may introduce data races}}
5959
}
6060

@@ -140,8 +140,8 @@ private struct StructContainingValue { // expected-complete-note 2{{}}
140140

141141
x.1 = firstList
142142

143-
// TODO: This should be a global actor isolated error, not a task isolated error.
144-
await transferToNonIsolated(x) // expected-tns-warning {{task isolated value of type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' transferred to nonisolated context}}
143+
// TODO: This should be a global actor isolated error, not a task-isolated error.
144+
await transferToNonIsolated(x) // expected-tns-warning {{task-isolated value of type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' transferred to nonisolated context}}
145145
// expected-complete-warning @-1 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
146146
// expected-complete-warning @-2 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
147147

test/Concurrency/transfernonsendable_globalactors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ struct CustomActor {
4040

4141
@MainActor func testTransferGlobalActorGuardedValue() async {
4242
// TODO: Global actor error needed.
43-
await transferToCustom(globalKlass) // expected-warning {{task isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context}}
43+
await transferToCustom(globalKlass) // expected-warning {{task-isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context}}
4444
}
4545

4646
@MainActor func testTransferGlobalActorGuardedValueWithlet() async {
4747
let x = globalKlass
48-
await transferToCustom(x) // expected-warning {{task isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context}}
48+
await transferToCustom(x) // expected-warning {{task-isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context}}
4949
}
5050

5151
@MainActor func testTransferGlobalActorGuardedValueWithlet(_ k: Klass) async {
52-
// expected-note @-1 {{value is task isolated since it is in the same region as 'k'}}
52+
// expected-note @-1 {{value is task-isolated since it is in the same region as 'k'}}
5353
globalKlass = k
54-
await transferToCustom(k) // expected-warning {{task isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context; later accesses to value could race}}
54+
await transferToCustom(k) // expected-warning {{task-isolated value of type 'Klass' transferred to global actor 'CustomActor'-isolated context; later accesses to value could race}}
5555
}

0 commit comments

Comments
 (0)