@@ -51,7 +51,7 @@ public func basic_return1() -> Triangle {
51
51
52
52
@_manualOwnership
53
53
public func basic_return2( t: Triangle ) -> Triangle {
54
- return t // expected-error {{ownership of 't' is demanded }}
54
+ return t // expected-error {{independent copy of 't' is required here; write 'copy' to acknowledge or 'consume' to elide }}
55
55
}
56
56
@_manualOwnership
57
57
public func basic_return2_fixed( t: Triangle ) -> Triangle {
@@ -65,7 +65,7 @@ public func basic_return3() -> Triangle {
65
65
66
66
@_manualOwnership
67
67
func return_borrowed( _ t: borrowing Triangle ) -> Triangle {
68
- return t // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
68
+ return t // expected-error {{independent copy of 't' is required here; write 'copy' to acknowledge or 'consume' to elide }}
69
69
}
70
70
@_manualOwnership
71
71
func return_borrowed_fixed( _ t: borrowing Triangle ) -> Triangle {
@@ -75,7 +75,7 @@ func return_borrowed_fixed(_ t: borrowing Triangle) -> Triangle {
75
75
// FIXME: there's no workaround to this; it acts like a var so it's the same class of problem (rdar://161359163)
76
76
@_manualOwnership
77
77
func return_consumingParam( _ t: consuming Triangle ) -> Triangle {
78
- return t // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
78
+ return t // expected-error {{independent copy of 't' is required here; write 'copy' to acknowledge or 'consume' to elide }}
79
79
}
80
80
@_manualOwnership
81
81
func return_consumingParam_no_workaround( _ t: consuming Triangle ) -> Triangle {
@@ -100,8 +100,8 @@ func renamed_return(_ cond: Bool, _ a: Triangle) -> Triangle {
100
100
let b = a
101
101
let c = b
102
102
// FIXME: we say 'c' instead of 'b', because of the propagation. (rdar://161360537)
103
- if cond { return b } // expected-error {{ownership of 'c' is demanded }}
104
- return c // expected-error {{ownership of 'c' is demanded }}
103
+ if cond { return b } // expected-error {{independent copy of 'c' is required }}
104
+ return c // expected-error {{independent copy of 'c' is required }}
105
105
}
106
106
107
107
@_manualOwnership
@@ -133,7 +133,7 @@ func basic_methods_borrowing(_ t1: Triangle) {
133
133
@_manualOwnership
134
134
func basic_methods_consuming( _ t1: Triangle ) {
135
135
let t2 = Triangle ( )
136
- t1. consuming ( ) // expected-error {{ownership of 't1' is demanded }}
136
+ t1. consuming ( ) // expected-error {{independent copy of 't1' is required }}
137
137
t2. consuming ( )
138
138
}
139
139
@_manualOwnership
@@ -153,7 +153,7 @@ func plainFunc(_ t0: Triangle) {}
153
153
154
154
@_manualOwnership
155
155
func basic_function_call( _ t1: Triangle ) {
156
- consumingFunc ( t1) // expected-error {{ownership of 't1' is demanded }}
156
+ consumingFunc ( t1) // expected-error {{independent copy of 't1' is required }}
157
157
consumingFunc ( copy t1 )
158
158
plainFunc ( t1)
159
159
}
@@ -163,8 +163,8 @@ func basic_function_call(_ t1: Triangle) {
163
163
@_manualOwnership
164
164
func check_vars( _ t: Triangle , _ b: Bool ) -> Triangle {
165
165
var x = Triangle ( )
166
- if b { x = t } // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
167
- return x // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
166
+ if b { x = t } // expected-error {{independent copy of 't' is required }}
167
+ return x // expected-error {{independent copy of 'x' is required }}
168
168
}
169
169
@_manualOwnership
170
170
func check_vars_fixed( _ t: Triangle , _ b: Bool ) -> Triangle {
@@ -180,7 +180,7 @@ func check_vars_fixed(_ t: Triangle, _ b: Bool) -> Triangle {
180
180
func reassignments_0( ) -> Triangle {
181
181
var t3 = Triangle ( )
182
182
t3 = Triangle ( )
183
- return t3 // expected-error {{ownership of 't3' is demanded }}
183
+ return t3 // expected-error {{independent copy of 't3' is required }}
184
184
}
185
185
@_manualOwnership
186
186
func reassignments_0_fixed_1( ) -> Triangle {
@@ -199,7 +199,7 @@ func reassignments_0_fixed_2() -> Triangle {
199
199
func reassignments_1( ) {
200
200
var t3 = Triangle ( )
201
201
t3 = Triangle ( )
202
- t3. borrowing ( ) // expected-error {{accessing 't3' produces a copy of it }}
202
+ t3. borrowing ( ) // expected-error {{accessing 't3' may produce a copy; write 'copy' to acknowledge or 'consume' to elide }}
203
203
}
204
204
@_manualOwnership
205
205
func reassignments_1_fixed_1( ) {
@@ -217,7 +217,7 @@ func reassignments_1_fixed_2() {
217
217
@_manualOwnership
218
218
public func basic_loop_trivial_values( _ t: Triangle , _ xs: [ Triangle ] ) {
219
219
var p : Pair = t. a
220
- for x in xs { // expected-error {{ownership of 'xs' is demanded }}
220
+ for x in xs { // expected-error {{independent copy of 'xs' is required }}
221
221
p = p. midpoint ( x. a)
222
222
}
223
223
t. a = p
@@ -239,11 +239,11 @@ public func basic_loop_trivial_values_fixed(_ t: Triangle, _ xs: [Triangle]) {
239
239
240
240
@_manualOwnership
241
241
public func basic_loop_nontrivial_values( _ t: Triangle , _ xs: [ Triangle ] ) {
242
- var p : Pair = t. nontrivial. a // expected-error {{accessing 't.nontrivial' produces a copy of it }}
243
- for x in xs { // expected-error {{ownership of 'xs' is demanded }}
244
- p = p. midpoint ( x. nontrivial. a) // expected-error {{accessing 'x.nontrivial' produces a copy of it }}
242
+ var p : Pair = t. nontrivial. a // expected-error {{accessing 't.nontrivial' may produce a copy}}
243
+ for x in xs { // expected-error {{independent copy of 'xs' is required }}
244
+ p = p. midpoint ( x. nontrivial. a) // expected-error {{accessing 'x.nontrivial' may produce a copy}}
245
245
}
246
- t. nontrivial. a = p // expected-error {{accessing 't.nontrivial' produces a copy of it }}
246
+ t. nontrivial. a = p // expected-error {{accessing 't.nontrivial' may produce a copy}}
247
247
}
248
248
249
249
@_manualOwnership
@@ -258,10 +258,10 @@ public func basic_loop_nontrivial_values_fixed(_ t: Triangle, _ xs: [Triangle])
258
258
@_manualOwnership
259
259
public func basic_loop_nontrivial_values_reduced_copies( _ t: Triangle , _ xs: [ Triangle ] ) {
260
260
// FIXME: confusing variable names are chosen (rdar://161360537)
261
- let nt = t. nontrivial // expected-error {{accessing 'nt' produces a copy of it }}
261
+ let nt = t. nontrivial // expected-error {{accessing 'nt' may produce a copy}}
262
262
var p : Pair = nt. a
263
263
for x in copy xs {
264
- let xnt = x. nontrivial // expected-error {{accessing 'xnt' produces a copy of it }}
264
+ let xnt = x. nontrivial // expected-error {{accessing 'xnt' may produce a copy}}
265
265
p = p. midpoint ( xnt. a)
266
266
}
267
267
nt. a = p
@@ -285,7 +285,7 @@ let ref_result = [5, 13, 29]
285
285
// are present to avoid exclusivity issues. We'd need to start generating read coroutines.
286
286
@_manualOwnership
287
287
func access_global_1( ) -> Int {
288
- return ref_result [ 2 ] // expected-error {{accessing 'ref_result' produces a copy of it }}
288
+ return ref_result [ 2 ] // expected-error {{accessing 'ref_result' may produce a copy}}
289
289
}
290
290
@_manualOwnership
291
291
func access_global_1_fixed( ) -> Int {
@@ -296,23 +296,23 @@ return (copy ref_result)[2]
296
296
297
297
@_manualOwnership
298
298
func closure_basic( _ t: Triangle ) -> ( ) -> Triangle {
299
- return { // expected-error {{ownership of 't' is demanded by a closure }}
300
- return t // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
299
+ return { // expected-error {{closure capture of 't' requires independent copy of it; write [t = copy t] }}
300
+ return t // expected-error {{independent copy of 't' is required }}
301
301
}
302
302
}
303
303
@_manualOwnership
304
304
func closure_basic_almost_fixed_1( _ t: Triangle ) -> ( ) -> Triangle {
305
305
// FIXME: Closure capture lists need to support the short-hand [copy t] that makes the
306
306
// closure capture parameter @owned, rather than @guaranteed. Only can work for Copyable types!
307
307
return { [ x = copy t] in
308
- return x // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
308
+ return x // expected-error {{independent copy of 'x' is required }}
309
309
}
310
310
}
311
311
312
312
@_manualOwnership
313
- func closure_basic_almost_fixed_2( _ t : Triangle ) -> ( ) -> Triangle {
314
- return { // expected-error {{ownership of 't' is demanded by a closure }}
315
- return copy t
313
+ func closure_basic_almost_fixed_2( _ x : Triangle ) -> ( ) -> Triangle {
314
+ return { // expected-error {{closure capture of 'x' requires independent copy of it; write [x = copy x] }}
315
+ return copy x
316
316
}
317
317
}
318
318
@@ -326,20 +326,20 @@ func closure_basic_fixed(_ t: Triangle) -> () -> Triangle {
326
326
@_manualOwnership
327
327
func closure_copies_in_body( _ t: Triangle ) -> ( ) -> Triangle {
328
328
return { [ x = copy t] in
329
- eat ( x) // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
329
+ eat ( x) // expected-error {{independent copy of 'x' is required }}
330
330
use ( x)
331
- eat ( x) // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
332
- return x // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
331
+ eat ( x) // expected-error {{independent copy of 'x' is required }}
332
+ return x // expected-error {{independent copy of 'x' is required }}
333
333
}
334
334
}
335
335
336
336
@_manualOwnership
337
337
func closure_copies_in_body_noescape( _ t: Triangle ) -> Triangle {
338
338
let f = { [ x = copy t] in
339
- eat ( x) // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
339
+ eat ( x) // expected-error {{independent copy of 'x' is required }}
340
340
use ( x)
341
- eat ( x) // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
342
- return x // expected-error {{ownership of 'x' is demanded and cannot not be consumed }}
341
+ eat ( x) // expected-error {{independent copy of 'x' is required }}
342
+ return x // expected-error {{independent copy of 'x' is required }}
343
343
}
344
344
return f ( )
345
345
}
@@ -355,7 +355,7 @@ func try_to_assert(_ n: Int, _ names: [String]) {
355
355
356
356
@_manualOwnership
357
357
func copy_in_autoclosure( _ t: Triangle ) {
358
- simple_assert ( consumingFunc ( t) ) // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
358
+ simple_assert ( consumingFunc ( t) ) // expected-error {{independent copy of 't' is required }}
359
359
}
360
360
@_manualOwnership
361
361
func copy_in_autoclosure_fixed( _ t: Triangle ) {
@@ -364,11 +364,11 @@ func copy_in_autoclosure_fixed(_ t: Triangle) {
364
364
365
365
@_manualOwnership
366
366
func nested_closures( _ t: Triangle ) -> ( ) -> ( ( ) -> Triangle ) {
367
- return { // expected-error {{ownership of 't' is demanded by a closure }}
368
- { eat ( t) } ( ) // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
369
- return { // expected-error {{ownership of 't' is demanded by a closure }}
370
- simple_assert ( consumingFunc ( t) ) // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
371
- return t // expected-error {{ownership of 't' is demanded and cannot not be consumed }}
367
+ return { // expected-error {{closure capture of 't' requires independent copy of it; write [t = copy t] }}
368
+ { eat ( t) } ( ) // expected-error {{independent copy of 't' is required }}
369
+ return { // expected-error {{closure capture of 't' requires independent copy of it; write [t = copy t] }}
370
+ simple_assert ( consumingFunc ( t) ) // expected-error {{independent copy of 't' is required }}
371
+ return t // expected-error {{independent copy of 't' is required }}
372
372
}
373
373
}
374
374
}
@@ -387,7 +387,7 @@ func nested_closures_fixed(_ t: Triangle) -> () -> (() -> Triangle) {
387
387
388
388
@_manualOwnership
389
389
func return_generic< T> ( _ t: T ) -> T {
390
- return t // expected-error {{accessing 't' produces a copy}}
390
+ return t // expected-error {{accessing 't' may produce a copy}}
391
391
}
392
392
@_manualOwnership
393
393
func return_generic_fixed< T> ( _ t: T ) -> T {
@@ -396,9 +396,9 @@ func return_generic_fixed<T>(_ t: T) -> T {
396
396
397
397
@_manualOwnership
398
398
func reassign_with_lets< T> ( _ t: T ) -> T {
399
- let x = t // expected-error {{accessing 't' produces a copy}}
400
- let y = x // expected-error {{accessing 'x' produces a copy}}
401
- let z = y // expected-error {{accessing 'y' produces a copy}}
399
+ let x = t // expected-error {{accessing 't' may produce a copy}}
400
+ let y = x // expected-error {{accessing 'x' may produce a copy}}
401
+ let z = y // expected-error {{accessing 'y' may produce a copy}}
402
402
return copy z
403
403
}
404
404
@@ -413,9 +413,9 @@ func reassign_with_lets_fixed<T>(_ t: T) -> T {
413
413
414
414
@_manualOwnership
415
415
func copy_generic< T> ( _ t: T ) {
416
- consume_generic ( t) // expected-error {{accessing 't' produces a copy}}
416
+ consume_generic ( t) // expected-error {{accessing 't' may produce a copy}}
417
417
borrow_generic ( t)
418
- consume_generic ( t) // expected-error {{accessing 't' produces a copy}}
418
+ consume_generic ( t) // expected-error {{accessing 't' may produce a copy}}
419
419
}
420
420
421
421
@_manualOwnership
@@ -429,10 +429,10 @@ func copy_generic_fixed<T>(_ t: T) {
429
429
func benchCaptureProp< S : Sequence > (
430
430
_ s: S , _ f: ( S . Element , S . Element ) -> S . Element ) -> S . Element {
431
431
432
- var it = s. makeIterator ( ) // expected-error {{accessing 's' produces a copy}}
432
+ var it = s. makeIterator ( ) // expected-error {{accessing 's' may produce a copy}}
433
433
let initial = it. next ( ) !
434
434
return
435
- IteratorSequence ( it) // expected-error {{accessing 'it' produces a copy}}
435
+ IteratorSequence ( it) // expected-error {{accessing 'it' may produce a copy}}
436
436
. reduce ( initial, f)
437
437
}
438
438
@_manualOwnership
@@ -464,8 +464,8 @@ struct CollectionOf32BitLittleEndianIntegers<BaseCollection: Collection> where B
464
464
@_manualOwnership
465
465
init ( _ baseCollection: BaseCollection ) {
466
466
precondition ( baseCollection. count % 4 == 0 )
467
- self . baseCollection = baseCollection // expected-error {{accessing 'baseCollection' produces a copy}}
468
- } // expected-error {{accessing 'self' produces a copy of it }}
467
+ self . baseCollection = baseCollection // expected-error {{accessing 'baseCollection' may produce a copy}}
468
+ } // expected-error {{accessing 'self' may produce a copy}}
469
469
470
470
// FIXME: the above initializer shouldn't have any diagnostics
471
471
}
0 commit comments