Skip to content

Commit 92782a0

Browse files
committed
Add an initializer for Span without lifetime dependence
Without this, supported old compilers which don't recognize LifetimeDependence feature but recognize the NonEscapableTypes feature will run into lifetime dependence inference errors on the implicit initializer generated for the stdlib's swiftinterface
1 parent e8abd59 commit 92782a0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

stdlib/public/core/Span/RawSpan.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public struct RawSpan: ~Escapable, Copyable, BitwiseCopyable {
4444
@usableFromInline
4545
internal let _count: Int
4646

47+
/// FIXME: Remove once supported old compilers can recognize lifetime dependence
48+
@_unsafeNonescapableResult
49+
@_alwaysEmitIntoClient
50+
@inline(__always)
51+
internal init() {
52+
_pointer = nil
53+
_count = 0
54+
}
55+
4756
/// Unsafely create a `RawSpan` over initialized memory.
4857
///
4958
/// `pointer` must point to a region of `byteCount` initialized bytes,

stdlib/public/core/Span/Span.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ public struct Span<Element: ~Copyable & ~Escapable>
4646
@usableFromInline
4747
internal let _count: Int
4848

49+
/// FIXME: Remove once supported old compilers can recognize lifetime dependence
50+
@_unsafeNonescapableResult
51+
@_alwaysEmitIntoClient
52+
@inline(__always)
53+
internal init() {
54+
_pointer = nil
55+
_count = 0
56+
}
57+
4958
/// Unsafely create a `Span` over initialized memory.
5059
///
5160
/// `pointer` must point to a region of `count` initialized instances,

0 commit comments

Comments
 (0)