You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/SILOptimizer/moveonly_nonescaping_closures.swift
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -60,8 +60,7 @@ func c(x: __owned M) {
60
60
61
61
func d(x:__owned M){ // expected-error {{'x' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
62
62
clodger({consume(x)})
63
-
// expected-error @-1 {{copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug}}
publicfunc closureCaptureClassUseAfterConsume1(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2139
+
varx2= x // expected-note {{consuming use here}}
2140
+
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
2141
+
// expected-error @-2 {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
publicfunc deferCaptureClassUseAfterConsume(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2192
2234
letx2= x // expected-note {{consuming use here}}
2235
+
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2193
2236
defer{
2194
2237
borrowVal(x2)
2195
-
consumeVal(x2)
2196
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2197
-
consumeVal(x2)
2198
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2238
+
// TODO: Defer can only run once, so this error shouldn't occur.
2239
+
consumeVal(x2) // expected-note {{consuming use here}}
2240
+
consumeVal(x2) // expected-note {{consuming use here}}
2199
2241
}
2200
2242
consumeVal(x) // expected-note {{consuming use here}}
2201
2243
}
2202
2244
2203
2245
publicfunc deferCaptureClassUseAfterConsume2(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2204
2246
letx2= x
2205
2247
// expected-note @-1 {{consuming use here}}
2206
-
defer{
2248
+
// expected-error @-2 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2249
+
// expected-error @-3 {{'x2' used after consume}}
2250
+
defer{ // expected-note {{non-consuming use here}}
2207
2251
borrowVal(x2)
2208
-
consumeVal(x2)
2209
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2210
-
consumeVal(x2)
2211
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2252
+
consumeVal(x2) // expected-note {{consuming use here}}
2253
+
consumeVal(x2) // expected-note {{consuming use here}}
2212
2254
}
2213
-
letx3= x2
2214
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2230
2272
defer{
2231
2273
borrowVal(x2)
2232
-
consumeVal(x2)
2233
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2234
-
consumeVal(x2)
2235
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2274
+
consumeVal(x2) // expected-note {{consuming use here}}
2275
+
consumeVal(x2) // expected-note {{consuming use here}}
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2282
+
// expected-error @-2 {{'x2' used after consume}}
2283
+
defer{ // expected-note {{non-consuming use here}}
2242
2284
borrowVal(x2)
2243
-
consumeVal(x2)
2244
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2245
-
consumeVal(x2)
2246
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2285
+
consumeVal(x2) // expected-note {{consuming use here}}
2286
+
consumeVal(x2) // expected-note {{consuming use here}}
2247
2287
}
2248
-
consumeVal(x2)
2249
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2288
+
consumeVal(x2) // expected-note {{consuming use here}}
2250
2289
}
2251
2290
2252
2291
publicfunc closureAndDeferCaptureClassUseAfterConsume(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2253
2292
letx2= x // expected-note {{consuming use here}}
2293
+
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2254
2294
letf={
2255
2295
defer{
2256
2296
borrowVal(x2)
2257
-
consumeVal(x2)
2258
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2259
-
consumeVal(x2)
2260
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2297
+
consumeVal(x2) // expected-note {{consuming use here}}
2298
+
consumeVal(x2) // expected-note {{consuming use here}}
publicfunc closureAndDeferCaptureClassUseAfterConsume2(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2268
2306
letx2= x // expected-note {{consuming use here}}
2307
+
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2308
+
// expected-error @-2 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2269
2309
letf={
2270
-
consumeVal(x2)
2271
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2310
+
consumeVal(x2) // expected-note {{consuming use here}}
2272
2311
defer{
2273
2312
borrowVal(x2)
2274
-
consumeVal(x2)
2275
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2276
-
consumeVal(x2)
2277
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2313
+
consumeVal(x2) // expected-note {{consuming use here}}
2314
+
consumeVal(x2) // expected-note {{consuming use here}}
publicfunc closureAndDeferCaptureClassUseAfterConsume3(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2285
2322
letx2= x
2286
2323
// expected-note @-1 {{consuming use here}}
2287
-
letf={
2288
-
consumeVal(x2)
2289
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2324
+
// expected-error @-2 {{'x2' consumed more than once}}
2325
+
// expected-error @-3 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2326
+
// expected-error @-4 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2327
+
letf={ // expected-note {{consuming use here}}
2328
+
consumeVal(x2) // expected-note {{consuming use here}}
2290
2329
defer{
2291
2330
borrowVal(x2)
2292
-
consumeVal(x2)
2293
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2294
-
consumeVal(x2)
2295
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2331
+
consumeVal(x2) // expected-note {{consuming use here}}
2332
+
consumeVal(x2) // expected-note {{consuming use here}}
2296
2333
}
2297
2334
print("foo")
2298
2335
}
2299
2336
f()
2300
-
consumeVal(x2)
2301
-
// expected-error @-1 {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2337
+
consumeVal(x2) // expected-note {{consuming use here}}
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2319
2356
letf={
2320
2357
defer{
2321
2358
borrowVal(x2)
2322
-
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2323
-
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2359
+
consumeVal(x2) // expected-note {{consuming use here}}
2360
+
consumeVal(x2) // expected-note {{consuming use here}}
// expected-error @-1 {{'x2' consumed more than once}}
2369
+
// expected-error @-2 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
2370
+
letf={ // expected-note {{consuming use here}}
2332
2371
defer{
2333
2372
borrowVal(x2)
2334
-
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2335
-
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2373
+
consumeVal(x2) // expected-note {{consuming use here}}
2374
+
consumeVal(x2) // expected-note {{consuming use here}}
2336
2375
}
2337
2376
print("foo")
2338
2377
}
2339
2378
f()
2340
-
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
2379
+
consumeVal(x2) // expected-note {{consuming use here}}
2341
2380
}
2342
2381
2343
2382
publicfunc closureAndClosureCaptureClassUseAfterConsume(_ x:__shared Klass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
0 commit comments