Skip to content

Commit 1125f75

Browse files
committed
[test] sending Spans shouldn’t require copyability
1 parent 911fbb6 commit 1125f75

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/stdlib/Span/SpanTests.swift

+17
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,20 @@ suite.test("initialize from raw memory")
589589
let first = test(span)
590590
expectEqual(first, 0x07060504)
591591
}
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+
}

0 commit comments

Comments
 (0)