Skip to content

Commit f02172a

Browse files
committed
[region-isolation] Change terminology to use the term 'risk' instead of could.
1 parent a933c14 commit f02172a

28 files changed

+661
-661
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ NOTE(sil_referencebinding_inout_binding_here, none,
943943
//===----------------------------------------------------------------------===//
944944

945945
NOTE(regionbasedisolation_maybe_race, none,
946-
"use here could race", ())
946+
"risks concurrent access", ())
947947
ERROR(regionbasedisolation_unknown_pattern, none,
948948
"pattern that the region based isolation checker does not understand how to check. Please file a bug",
949949
())
@@ -979,7 +979,7 @@ NOTE(regionbasedisolation_isolated_since_in_same_region_basename, none,
979979
//
980980

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

985985
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,

test/ClangImporter/transferring.swift

Lines changed: 4 additions & 4 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 {{sending 'x2' may cause a data race}}
30+
await transferToMain(x2) // expected-error {{sending 'x2' risks causing data races}}
3131
// expected-note @-1 {{sending disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
32-
useValue(y2) // expected-note {{use here could race}}
32+
useValue(y2) // expected-note {{risks concurrent access}}
3333
}
3434

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

test/ClangImporter/transferring_objc.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func methodTestTransferringResult() async {
2525
func methodTestTransferringArg() async {
2626
let x = MyType()
2727
let s = NSObject()
28-
let _ = x.getResultWithTransferringArgument(s) // expected-error {{sending 's' may cause a data race}}
28+
let _ = x.getResultWithTransferringArgument(s) // expected-error {{sending 's' risks causing data races}}
2929
// expected-note @-1 {{'s' used after being passed as a transferring parameter; Later uses could race}}
30-
useValue(s) // expected-note {{use here could race}}
30+
useValue(s) // expected-note {{risks concurrent access}}
3131
}
3232

3333
// Make sure we just ignore the swift_attr if it is applied to something like a
@@ -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 {{sending 'x2' may cause a data race}}
48+
await transferToMain(x2) // expected-error {{sending 'x2' risks causing data races}}
4949
// expected-note @-1 {{sending disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
50-
useValue(y2) // expected-note {{use here could race}}
50+
useValue(y2) // expected-note {{risks concurrent access}}
5151
}
5252

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

test/Concurrency/async_task_locals_basic_warnings_bug_isolation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ actor Test {
1818
_ body: (consuming NonSendableValue, isolated (any Actor)?) -> Void) async {
1919
Self.$local.withValue(12) {
2020
// Unexpected errors here:
21-
// error: unexpected warning produced: transferring 'body' may cause a data race; this is an error in the Swift 6 language mode
21+
// error: unexpected warning produced: transferring 'body' risks causing data races; this is an error in the Swift 6 language mode
2222
// error: unexpected note produced: actor-isolated 'body' is captured by a actor-isolated closure. actor-isolated uses in closure may race against later nonisolated uses
2323
body(NonSendableValue(), isolation)
2424
}

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 {{sending 'ns' may cause a data race}}
43+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
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 {{sending 'ns' may cause a data race}}
65+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
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 {{sending 'ns' may cause a data race}}
86+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
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/sendable_checking.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ 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 {{sending 'ns1' may cause a data race}}
99+
// expected-tns-warning @-1 {{sending 'ns1' risks causing data races}}
100100
// expected-tns-note @-2 {{sending actor-isolated 'ns1' to nonisolated global function 'nonisolatedAsyncFunc1' risks causing data 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
}
@@ -253,12 +253,12 @@ 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 {{sending 'self' may cause a data race}}
256+
// expected-tns-warning @-2 {{sending 'self' risks causing data races}}
257257
// expected-tns-note @-3 {{sending task-isolated 'self' to main actor-isolated instance method 'update()' risks causing data 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 {{sending 'self' may cause a data race}}
261+
// expected-tns-warning @-2 {{sending 'self' risks causing data races}}
262262
// expected-tns-note @-3 {{sending task-isolated 'self' to main actor-isolated instance method 'update()' risks causing data races between main actor-isolated and task-isolated uses}}
263263

264264
_ = await x
@@ -277,12 +277,12 @@ 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 {{sending 't' may cause a data race}}
280+
// expected-tns-warning @-2 {{sending 't' risks causing data races}}
281281
// expected-tns-note @-3 {{sending 't' to main actor-isolated instance method 'update()' risks causing data races between 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}}
285-
// expected-tns-note@-2 {{use here could race}}
285+
// expected-tns-note@-2 {{risks concurrent access}}
286286
}
287287

288288
@available(SwiftStdlib 5.1, *)
@@ -297,13 +297,13 @@ 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 {{sending 'ns' may cause a data race}}
300+
// expected-tns-warning @-2 {{sending 'ns' risks causing data races}}
301301
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data 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 {{sending 'ns' may cause a data race}}
306+
// expected-tns-warning @-2 {{sending 'ns' risks causing data races}}
307307
// expected-tns-note @-3 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data races between nonisolated and main actor-isolated uses}}
308308
}
309309

test/Concurrency/transfernonsendable.sil

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ bb0:
160160
// expected-warning @-1 {{sending value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context}}
161161
%useIndirect = function_ref @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
162162
apply %useIndirect<NonSendableKlass>(%1) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
163-
// expected-note @-1 {{use here could race}}
163+
// expected-note @-1 {{risks concurrent access}}
164164

165165
destroy_addr %1 : $*NonSendableKlass
166166
dealloc_stack %1 : $*NonSendableKlass
@@ -226,7 +226,7 @@ bb0(%0 : @guaranteed $NonSendableStruct):
226226
debug_value %0 : $NonSendableStruct, var, name "myname"
227227
%2 = struct_extract %0 : $NonSendableStruct, #NonSendableStruct.ns
228228
%3 = copy_value %2 : $NonSendableKlass
229-
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' may cause a data race}}
229+
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' risks causing data races}}
230230
// expected-note @-1 {{task-isolated 'myname.ns' cannot be a transferring result. task-isolated uses may race with caller uses}}
231231
}
232232

@@ -235,7 +235,7 @@ bb0(%0 : @guaranteed $MainActorIsolatedStruct):
235235
debug_value %0 : $MainActorIsolatedStruct, var, name "myname"
236236
%2 = struct_extract %0 : $MainActorIsolatedStruct, #MainActorIsolatedStruct.ns
237237
%3 = copy_value %2 : $NonSendableKlass
238-
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' may cause a data race}}
238+
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' risks causing data races}}
239239
// expected-note @-1 {{main actor-isolated 'myname.ns' cannot be a transferring result. main actor-isolated uses may race with caller uses}}
240240
}
241241

@@ -244,7 +244,7 @@ bb0(%0 : $*MainActorIsolatedStruct):
244244
debug_value %0 : $*MainActorIsolatedStruct, var, name "myname"
245245
%2 = struct_element_addr %0 : $*MainActorIsolatedStruct, #MainActorIsolatedStruct.ns
246246
%3 = load [copy] %2 : $*NonSendableKlass
247-
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' may cause a data race}}
247+
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.ns' risks causing data races}}
248248
// expected-note @-1 {{main actor-isolated 'myname.ns' cannot be a transferring result. main actor-isolated uses may race with caller uses}}
249249
}
250250

@@ -253,7 +253,7 @@ bb0(%0 : @guaranteed $MainActorIsolatedEnum):
253253
debug_value %0 : $MainActorIsolatedEnum, var, name "myname"
254254
%2 = unchecked_enum_data %0 : $MainActorIsolatedEnum, #MainActorIsolatedEnum.second!enumelt
255255
%3 = copy_value %2 : $NonSendableKlass
256-
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.second' may cause a data race}}
256+
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.second' risks causing data races}}
257257
// expected-note @-1 {{main actor-isolated 'myname.second' cannot be a transferring result. main actor-isolated uses may race with caller uses}}
258258
}
259259

@@ -262,7 +262,7 @@ bb0(%0 : $*MainActorIsolatedEnum):
262262
debug_value %0 : $*MainActorIsolatedEnum, var, name "myname"
263263
%2 = unchecked_take_enum_data_addr %0 : $*MainActorIsolatedEnum, #MainActorIsolatedEnum.second!enumelt
264264
%3 = load [take] %2 : $*NonSendableKlass
265-
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.second' may cause a data race}}
265+
return %3 : $NonSendableKlass // expected-warning {{sending 'myname.second' risks causing data races}}
266266
// expected-note @-1 {{main actor-isolated 'myname.second' cannot be a transferring result. main actor-isolated uses may race with caller uses}}
267267
}
268268

@@ -281,7 +281,7 @@ bb2(%1 : @guaranteed $NonSendableKlass):
281281
br bb3(%3 : $FakeOptional<NonSendableKlass>)
282282

283283
bb3(%4 : @owned $FakeOptional<NonSendableKlass>):
284-
return %4 : $FakeOptional<NonSendableKlass> // expected-warning {{sending 'myname.some' may cause a data race}}
284+
return %4 : $FakeOptional<NonSendableKlass> // expected-warning {{sending 'myname.some' risks causing data races}}
285285
// expected-note @-1 {{main actor-isolated 'myname.some' cannot be a transferring result. main actor-isolated uses may race with caller uses}}
286286
}
287287

0 commit comments

Comments
 (0)