@@ -459,6 +459,12 @@ public func finalClassSimpleNonConsumingUseTest(_ x: __owned FinalKlass) {
459
459
borrowVal ( x2)
460
460
}
461
461
462
+ public func finalClassSimpleNonConsumingUseTest2( _ x: consuming FinalKlass ) {
463
+ var x2 = x
464
+ x2 = FinalKlass ( )
465
+ borrowVal ( x2)
466
+ }
467
+
462
468
public func finalClassSimpleNonConsumingUseTestArg( _ x2: inout FinalKlass ) {
463
469
borrowVal ( x2)
464
470
}
@@ -2142,6 +2148,24 @@ func moveOperatorTest(_ k: __owned Klass) {
2142
2148
let _ = k3
2143
2149
}
2144
2150
2151
+ func moveOperatorTest2( _ k: consuming Klass ) {
2152
+ var k2 = k
2153
+ // expected-error @-1 {{'k2' consumed more than once}}
2154
+ // expected-error @-2 {{'k2' consumed more than once}}
2155
+ // expected-error @-3 {{'k2' consumed more than once}}
2156
+ k2 = Klass ( )
2157
+ let k3 = consume k2 // expected-note {{consuming use here}}
2158
+ let _ = consume k2
2159
+ // expected-note @-1 {{consuming use here}}
2160
+ // expected-note @-2 {{consuming use here}}
2161
+ _ = k2
2162
+ // expected-note @-1 {{consuming use here}}
2163
+ // expected-note @-2 {{consuming use here}}
2164
+ let _ = k2
2165
+ // expected-note @-1 {{consuming use here}}
2166
+ let _ = k3
2167
+ }
2168
+
2145
2169
/////////////////////////////////////////
2146
2170
// Black hole initialization test case//
2147
2171
/////////////////////////////////////////
@@ -2170,6 +2194,30 @@ func blackHoleKlassTestCase(_ k: __owned Klass) {
2170
2194
// expected-note @-1 {{consuming use here}}
2171
2195
}
2172
2196
2197
+ func blackHoleKlassTestCase2( _ k: consuming Klass ) {
2198
+ var k2 = k
2199
+ // expected-error @-1 {{'k2' consumed more than once}}
2200
+ // expected-error @-2 {{'k2' consumed more than once}}
2201
+ // expected-error @-3 {{'k2' consumed more than once}}
2202
+ // expected-error @-4 {{'k2' consumed more than once}}
2203
+ let _ = k2 // expected-note {{consuming use here}}
2204
+ let _ = k2 // expected-note {{consuming use here}}
2205
+
2206
+ k2 = Klass ( )
2207
+ var _ = k2 // expected-note {{consuming use here}}
2208
+ var _ = k2
2209
+ // expected-note @-1 {{consuming use here}}
2210
+ // expected-note @-2 {{consuming use here}}
2211
+
2212
+ _ = k2
2213
+ // expected-note @-1 {{consuming use here}}
2214
+ // expected-note @-2 {{consuming use here}}
2215
+
2216
+ // TODO: Why do we not also get 2 errors here?
2217
+ _ = k2
2218
+ // expected-note @-1 {{consuming use here}}
2219
+ }
2220
+
2173
2221
///////////////////////////////////////
2174
2222
// Copyable Type in a Move Only Type //
2175
2223
///////////////////////////////////////
@@ -2451,6 +2499,14 @@ func borrowAndConsumeAtSameTimeTest(x: __owned NonTrivialStruct) { // expected-e
2451
2499
// expected-note @-2 {{non-consuming use here}}
2452
2500
}
2453
2501
2502
+ func borrowAndConsumeAtSameTimeTest2( x: consuming NonTrivialStruct ) { // expected-error {{'x' used after consume}}
2503
+ borrowAndConsumeAtSameTime ( x, consume: x)
2504
+ // expected-note @-1 {{consuming use here}}
2505
+ // expected-note @-2 {{non-consuming use here}}
2506
+ // expected-error @-3 {{overlapping accesses to 'x', but deinitialization requires exclusive access; consider copying to a local variable}}
2507
+ // expected-note @-4 {{conflicting access is here}}
2508
+ }
2509
+
2454
2510
////////////////
2455
2511
// Yield Test //
2456
2512
////////////////
0 commit comments