Skip to content

Commit 7368de2

Browse files
committed
[region-isolation] Remove variable_defined_here from named use after transfer error.
This is just a pseudo-why are these two things part of the same region error. I am going to remove this for now and the proper form of this diagnostic will come back when I land the region history functionality.
1 parent f24e18c commit 7368de2

9 files changed

+45
-56
lines changed

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ class UseAfterTransferDiagnosticEmitter {
479479
diag::regionbasedisolation_named_info_transfer_yields_race,
480480
name, isolationCrossing.getCallerIsolation(),
481481
isolationCrossing.getCalleeIsolation());
482-
// Then emit the note about where the variable is defined.
483-
diagnoseNote(variableDefinedLoc, diag::variable_defined_here,
484-
false /*variable*/);
485482
emitRequireInstDiagnostics();
486483
}
487484

test/Concurrency/experimental_feature_strictconcurrency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct Test2: TestProtocol { // expected-warning{{conformance of 'C2' to 'Sendab
2727

2828
@MainActor
2929
func iterate(stream: AsyncStream<Int>) async {
30-
nonisolated(unsafe) var it = stream.makeAsyncIterator() // expected-region-isolation-note {{variable defined here}}
30+
nonisolated(unsafe) var it = stream.makeAsyncIterator()
3131
// FIXME: Region isolation should consider a value from a 'nonisolated(unsafe)'
3232
// declaration to be in a disconnected region
3333

test/Concurrency/sendable_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ final class NonSendable {
274274

275275
@available(SwiftStdlib 5.1, *)
276276
func testNonSendableBaseArg() async {
277-
let t = NonSendable() // expected-tns-note {{variable defined here}}
277+
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}}
280280
// expected-tns-warning @-2 {{transferring 't' may cause a race}}

test/Concurrency/transfernonsendable.swift

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ extension FinalActor {
107107

108108
// This test makes sure that we can properly pattern match project_box.
109109
func formClosureWithoutCrashing() {
110-
var c = NonSendableKlass() // expected-warning {{variable 'c' was never mutated; consider changing to 'let' constant}}
110+
var c = NonSendableKlass() // expected-warning {{variable 'c' was never mutated; consider changing to 'let' constant}}
111111
let _ = { print(c) }
112112
}
113113

114114
// In this test, closure is not promoted into its box form. As a result, we
115115
// treat assignments into contents as a merge operation rather than an assign.
116116
func closureInOut(_ a: Actor) async {
117117
var contents = NonSendableKlass()
118-
let ns0 = NonSendableKlass() // expected-tns-note {{variable defined here}}
118+
let ns0 = NonSendableKlass()
119119
let ns1 = NonSendableKlass()
120120

121121
contents = ns0
@@ -141,8 +141,8 @@ func closureInOut(_ a: Actor) async {
141141

142142
func closureInOut2(_ a: Actor) async {
143143
var contents = NonSendableKlass()
144-
let ns0 = NonSendableKlass() // expected-tns-note {{variable defined here}}
145-
let ns1 = NonSendableKlass() // expected-tns-note {{variable defined here}}
144+
let ns0 = NonSendableKlass()
145+
let ns1 = NonSendableKlass()
146146

147147
contents = ns0
148148
contents = ns1
@@ -165,7 +165,7 @@ func closureInOut2(_ a: Actor) async {
165165
func closureNonInOut(_ a: Actor) async {
166166
var contents = NonSendableKlass()
167167
let ns0 = NonSendableKlass()
168-
let ns1 = NonSendableKlass() // expected-tns-note {{variable defined here}}
168+
let ns1 = NonSendableKlass()
169169

170170
contents = ns0
171171
contents = ns1
@@ -298,7 +298,7 @@ extension Actor {
298298
}
299299

300300
func simpleClosureCaptureSelfWithReinit3() async {
301-
var closure: () -> () = {} // expected-tns-note {{variable defined here}}
301+
var closure: () -> () = {}
302302

303303
// We get a transfer after use error.
304304
await transferToMain(closure) // expected-complete-warning {{passing argument of non-sendable type '() -> ()' into main actor-isolated context may introduce data races}}
@@ -498,7 +498,7 @@ extension Actor {
498498

499499
extension Actor {
500500
func testVarReassignStopActorDerived() async {
501-
var closure: () -> () = { // expected-tns-note {{variable defined here}}
501+
var closure: () -> () = {
502502
print(self)
503503
}
504504

@@ -566,7 +566,7 @@ func testSendableClosureCapturesNonSendable2(a: MainActorIsolatedKlass) {
566566
/////////////////////////////////////////////////////
567567

568568
func singleFieldVarMergeTest() async {
569-
var box = SingleFieldKlassBox() // expected-tns-note {{variable defined here}}
569+
var box = SingleFieldKlassBox()
570570
box = SingleFieldKlassBox()
571571

572572
// This transfers the entire region.
@@ -599,7 +599,7 @@ func singleFieldVarMergeTest() async {
599599
}
600600

601601
func multipleFieldVarMergeTest1() async {
602-
var box = TwoFieldKlassBox() // expected-tns-note {{variable defined here}}
602+
var box = TwoFieldKlassBox()
603603
box = TwoFieldKlassBox()
604604

605605
// This transfers the entire region.
@@ -640,7 +640,7 @@ func multipleFieldVarMergeTest2() async {
640640
}
641641

642642
func multipleFieldTupleMergeTest1() async {
643-
var box = (NonSendableKlass(), NonSendableKlass()) // expected-tns-note {{variable defined here}}
643+
var box = (NonSendableKlass(), NonSendableKlass())
644644
box = (NonSendableKlass(), NonSendableKlass())
645645

646646
// This transfers the entire region.
@@ -844,7 +844,7 @@ func letNonSendableNonTrivialLetStructFieldTest() async {
844844
}
845845

846846
func letSendableTrivialVarStructFieldTest() async {
847-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
847+
var test = StructFieldTests()
848848
test = StructFieldTests()
849849
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
850850
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -854,7 +854,7 @@ func letSendableTrivialVarStructFieldTest() async {
854854
}
855855

856856
func letSendableNonTrivialVarStructFieldTest() async {
857-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
857+
var test = StructFieldTests()
858858
test = StructFieldTests()
859859
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
860860
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -864,7 +864,7 @@ func letSendableNonTrivialVarStructFieldTest() async {
864864
}
865865

866866
func letNonSendableNonTrivialVarStructFieldTest() async {
867-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
867+
var test = StructFieldTests()
868868
test = StructFieldTests()
869869
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
870870
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -921,7 +921,7 @@ func varNonSendableNonTrivialLetStructFieldTest() async {
921921
}
922922

923923
func varSendableTrivialVarStructFieldTest() async {
924-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
924+
var test = StructFieldTests()
925925
test = StructFieldTests()
926926
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
927927
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -931,7 +931,7 @@ func varSendableTrivialVarStructFieldTest() async {
931931
}
932932

933933
func varSendableNonTrivialVarStructFieldTest() async {
934-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
934+
var test = StructFieldTests()
935935
test = StructFieldTests()
936936
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
937937
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -941,7 +941,7 @@ func varSendableNonTrivialVarStructFieldTest() async {
941941
}
942942

943943
func varNonSendableNonTrivialVarStructFieldTest() async {
944-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
944+
var test = StructFieldTests()
945945
test = StructFieldTests()
946946
await transferToMain(test) // expected-tns-warning {{transferring 'test' may cause a race}}
947947
// expected-tns-note @-1 {{'test' is transferred from nonisolated caller to main actor-isolated callee. Later uses in caller could race with potential uses in callee}}
@@ -953,7 +953,7 @@ func varNonSendableNonTrivialVarStructFieldTest() async {
953953

954954
// vars cannot access sendable let/var if captured in a closure.
955955
func varNonSendableNonTrivialLetStructFieldClosureTest1() async {
956-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
956+
var test = StructFieldTests()
957957
test = StructFieldTests()
958958
let cls = {
959959
test = StructFieldTests()
@@ -968,7 +968,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest1() async {
968968
}
969969

970970
func varNonSendableNonTrivialLetStructFieldClosureTest2() async {
971-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
971+
var test = StructFieldTests()
972972
test = StructFieldTests()
973973
let cls = {
974974
test = StructFieldTests()
@@ -983,7 +983,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest2() async {
983983
}
984984

985985
func varNonSendableNonTrivialLetStructFieldClosureTest3() async {
986-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
986+
var test = StructFieldTests()
987987
test = StructFieldTests()
988988
let cls = {
989989
test = StructFieldTests()
@@ -998,7 +998,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest3() async {
998998

999999
// vars cannot access sendable let/var if captured in a closure.
10001000
func varNonSendableNonTrivialLetStructFieldClosureTest4() async {
1001-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1001+
var test = StructFieldTests()
10021002
test = StructFieldTests()
10031003
var cls = {}
10041004
cls = {
@@ -1014,7 +1014,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest4() async {
10141014
}
10151015

10161016
func varNonSendableNonTrivialLetStructFieldClosureTest5() async {
1017-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1017+
var test = StructFieldTests()
10181018
test = StructFieldTests()
10191019
var cls = {}
10201020
cls = {
@@ -1030,7 +1030,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest5() async {
10301030
}
10311031

10321032
func varNonSendableNonTrivialLetStructFieldClosureTest6() async {
1033-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1033+
var test = StructFieldTests()
10341034
test = StructFieldTests()
10351035
var cls = {}
10361036
cls = {
@@ -1045,7 +1045,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest6() async {
10451045
}
10461046

10471047
func varNonSendableNonTrivialLetStructFieldClosureTest7() async {
1048-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1048+
var test = StructFieldTests()
10491049
test = StructFieldTests()
10501050
var cls = {}
10511051
cls = {
@@ -1060,7 +1060,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest7() async {
10601060
}
10611061

10621062
func varNonSendableNonTrivialLetStructFieldClosureTest8() async {
1063-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1063+
var test = StructFieldTests()
10641064
test = StructFieldTests()
10651065
var cls = {}
10661066
cls = {
@@ -1075,7 +1075,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest8() async {
10751075
}
10761076

10771077
func varNonSendableNonTrivialLetStructFieldClosureTest9() async {
1078-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1078+
var test = StructFieldTests()
10791079
test = StructFieldTests()
10801080
var cls = {}
10811081
cls = {
@@ -1090,7 +1090,7 @@ func varNonSendableNonTrivialLetStructFieldClosureTest9() async {
10901090
}
10911091

10921092
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive1() async {
1093-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1093+
var test = StructFieldTests()
10941094
test = StructFieldTests()
10951095
var cls = {}
10961096

@@ -1111,7 +1111,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive1() async {
11111111
}
11121112

11131113
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive2() async {
1114-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1114+
var test = StructFieldTests()
11151115
test = StructFieldTests()
11161116
var cls = {}
11171117

@@ -1133,7 +1133,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive2() async {
11331133
// We do not error when accessing the sendable field in this example since the
11341134
// transfer is not reachable from the closure. Instead we emit an error on test.
11351135
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive3() async {
1136-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1136+
var test = StructFieldTests()
11371137
test = StructFieldTests()
11381138
var cls = {}
11391139

@@ -1153,7 +1153,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive3() async {
11531153
}
11541154

11551155
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive4() async {
1156-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1156+
var test = StructFieldTests()
11571157
test = StructFieldTests()
11581158
var cls = {}
11591159

@@ -1179,7 +1179,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive4() async {
11791179
}
11801180

11811181
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive5() async {
1182-
var test = StructFieldTests() // expected-tns-note {{variable defined here}}
1182+
var test = StructFieldTests()
11831183
test = StructFieldTests()
11841184

11851185
// The reason why we error here is that even though we reassign at the end of
@@ -1202,7 +1202,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive5() async {
12021202
}
12031203

12041204
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive6() async {
1205-
var test = StructFieldTests() // expected-tns-note 2{{variable defined here}}
1205+
var test = StructFieldTests()
12061206
test = StructFieldTests()
12071207
var cls = {}
12081208

@@ -1230,7 +1230,7 @@ func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive6() async {
12301230
// In this case since we are tracking the transfer from the else statement, we
12311231
// track the closure.
12321232
func varNonSendableNonTrivialLetStructFieldClosureFlowSensitive7() async {
1233-
var test = StructFieldTests() // expected-tns-note 2{{variable defined here}}
1233+
var test = StructFieldTests()
12341234
test = StructFieldTests()
12351235
var cls = {}
12361236

@@ -1341,7 +1341,7 @@ func controlFlowTest1() async {
13411341
// as well afterwards since if we exit from the loop header, we have that large
13421342
// merge region leave the for loop.
13431343
func controlFlowTest2() async {
1344-
var x = NonSendableKlass() // expected-tns-note {{variable defined here}}
1344+
var x = NonSendableKlass()
13451345

13461346
for _ in 0..<1024 {
13471347
await transferToMain(x) // expected-tns-warning {{transferring 'x' may cause a race}}

test/Concurrency/transfernonsendable_global_actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private struct StructContainingValue { // expected-complete-note 2{{}}
103103
}
104104

105105
@GlobalActor func useGlobalActor6() async {
106-
var x = StructContainingValue() // expected-tns-note {{variable defined here}}
106+
var x = StructContainingValue()
107107
x = StructContainingValue()
108108

109109
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}

test/Concurrency/transfernonsendable_region_based_sendability.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ func test_indirect_regions(a : A, b : Bool) async {
246246

247247
// same aux value points to both 0 and 1
248248
let ns5_aux = NonSendable();
249-
let ns5_0 = ns5_aux.x; // expected-tns-note {{variable defined here}}
250-
let ns5_1 = ns5_aux.y; // expected-tns-note {{variable defined here}}
249+
let ns5_0 = ns5_aux.x;
250+
let ns5_1 = ns5_aux.y;
251251

252252
// now check for each pair that consuming half of it consumed the other half
253253

0 commit comments

Comments
 (0)