@@ -382,3 +382,49 @@ func copy_generic_fixed<T>(_ t: T) {
382
382
borrow_generic ( t)
383
383
consume_generic ( copy t)
384
384
}
385
+
386
+ @_manualOwnership
387
+ func benchCaptureProp< S : Sequence > (
388
+ _ s: S , _ f: ( S . Element , S . Element ) -> S . Element ) -> S . Element {
389
+
390
+ var it = s. makeIterator ( ) // expected-error {{explicit 'copy' required here}}
391
+ let initial = it. next ( ) !
392
+ return
393
+ IteratorSequence ( it) // expected-error {{explicit 'copy' required here}}
394
+ . reduce ( initial, f)
395
+ }
396
+ @_manualOwnership
397
+ func benchCaptureProp_fixed< S : Sequence > (
398
+ _ s: S , _ f: ( S . Element , S . Element ) -> S . Element ) -> S . Element {
399
+
400
+ var it = ( copy s) . makeIterator ( )
401
+ let initial = it. next ( ) !
402
+ return
403
+ IteratorSequence ( copy it)
404
+ . reduce ( initial, f)
405
+ }
406
+
407
+ extension FixedWidthInteger {
408
+ @_manualOwnership
409
+ func leftRotate( _ distance: Int ) -> Self {
410
+ return ( self << distance) | ( self >> ( Self . bitWidth - distance) )
411
+ }
412
+
413
+ @_manualOwnership
414
+ mutating func rotatedLeft( _ distance: Int ) {
415
+ // FIXME: this doesn't appear to be solvable
416
+ self = ( copy self) . leftRotate ( distance) // expected-error {{explicit 'copy' required here}}
417
+ }
418
+ }
419
+
420
+ struct CollectionOf32BitLittleEndianIntegers < BaseCollection: Collection > where BaseCollection. Element == UInt8 {
421
+ var baseCollection : BaseCollection
422
+
423
+ @_manualOwnership
424
+ init ( _ baseCollection: BaseCollection ) {
425
+ precondition ( baseCollection. count % 4 == 0 )
426
+ self . baseCollection = baseCollection // expected-error {{explicit 'copy' required here}}
427
+ } // expected-error {{explicit 'copy' required here}}
428
+
429
+ // FIXME: the above initializer shouldn't have any diagnostics
430
+ }
0 commit comments