File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public struct Span<Element: ~Copyable & ~Escapable>
84
84
}
85
85
86
86
@available ( SwiftStdlib 6 . 2 , * )
87
- extension Span : @unchecked Sendable where Element: Sendable { }
87
+ extension Span : @unchecked Sendable where Element: Sendable & ~ Copyable { }
88
88
89
89
@available ( SwiftStdlib 6 . 2 , * )
90
90
extension Span where Element: ~ Copyable {
Original file line number Diff line number Diff line change @@ -589,3 +589,20 @@ suite.test("initialize from raw memory")
589
589
let first = test ( span)
590
590
expectEqual ( first, 0x07060504 )
591
591
}
592
+
593
+ private func send( _: some Sendable & ~ Escapable) { }
594
+
595
+ private struct NCSendable : ~ Copyable, Sendable { }
596
+
597
+ suite. test ( " Span Sendability " )
598
+ . require ( . stdlib_6_2) . code {
599
+ guard #available( SwiftStdlib 6 . 2 , * ) else { return }
600
+
601
+ let buffer = UnsafeMutableBufferPointer< NCSendable> . allocate( capacity: 1 )
602
+ defer { buffer. deallocate ( ) }
603
+ buffer. initializeElement ( at: 0 , to: NCSendable ( ) )
604
+ defer { buffer. deinitialize ( ) }
605
+
606
+ let span = Span ( _unsafeElements: buffer)
607
+ send ( span)
608
+ }
You can’t perform that action at this time.
0 commit comments