Merge pull request #617 from lorentey/rigidly-enforced-lifetime-requirements

Fix lifetime requirements rigidly enforced in the latest nightlies
This commit is contained in:
Karoy Lorentey authored and GitHub committed 2026-04-03 17:38:32 -07:00
commit 324c48ac6b
6 files changed
+26 -17

No files matched your search

@@ -70,7 +70,7 @@ where Key: ~Copyable, Value: ~Copyable
@inlinable
public var underestimatedCount_: Int { self._base.value.count }
@_lifetime(copy self)
@_lifetime(borrow self) // FIXME: Should be @_lifetime(copy self)
public func makeBorrowingIterator_() -> BorrowingIterator_ {
let bit = self._base.value.makeBucketIterator()
// FIXME: This override really should not be necessary. Check if the real `struct Borrow` fixes it.
@@ -43,6 +43,8 @@ extension RigidSet: BorrowingSequence_ where Element: ~Copyable {
~Copyable,
~Escapable
{
public typealias Element_ = Element
@_alwaysEmitIntoClient
internal var _baseAddress: UnsafePointer<Element_>?
@@ -68,7 +70,7 @@ extension RigidSet: BorrowingSequence_ where Element: ~Copyable {
}
@_alwaysEmitIntoClient
@_lifetime(copy self)
@_lifetime(&self) // FIXME: This should be `@_lifetime(copy self)`
public mutating func nextSpan_(maximumCount: Int) -> Span<Element_> {
precondition(maximumCount > 0, "maximumCount must be positive")
guard
@@ -87,7 +87,9 @@ where Base.Element: ~Copyable
@available(SwiftStdlib 5.0, *)
extension ContainerFilter: BorrowingIteratorProtocol_ where Element: ~Copyable {
@_lifetime(copy self)
public typealias Element_ = Base.Element
@_lifetime(&self) // FIXME: This should be `@_lifetime(copy self)`
public mutating func nextSpan_(maximumCount: Int) -> Span<Element> {
precondition(maximumCount > 0)
while true {
@@ -52,23 +52,24 @@ where
{
public typealias Element_ = Base.Element
#if true
@_unsafeNonescapableResult // FIXME: we cannot convert from a borrow to an inout dependence?!
@_lifetime(&self)
public mutating func nextSpan_(maximumCount: Int) -> Span<Base.Element> {
_base.value.nextSpan(after: &self._position, maximumCount: maximumCount)
}
// @_lifetime(copy self)
// public mutating func nextSpan2(maximumCount: Int) -> Span<Base.Element> {
// var i = self._position
// let span = _base.value.nextSpan(
// after: &i,
// maximumCount: maximumCount)
// _ = consume span
// let result = _overrideLifetime(span, copying: self)
// self._position = i
// return .init()
// }
#else
@_lifetime(copy self)
public mutating func nextSpan(maximumCount: Int) -> Span<Base.Element> {
var i = self._position
let span = _base.value.nextSpan(
after: &i,
maximumCount: maximumCount)
self._position = i
let result = _overrideLifetime(span, copying: self)
return result
}
#endif
@_lifetime(self: copy self)
public mutating func skip_(by maximumOffset: Int) -> Int {
@@ -24,6 +24,8 @@ extension RigidDeque where Element: ~Copyable {
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@frozen
public struct BorrowingIterator: ~Escapable, BorrowingIteratorProtocol_ {
public typealias Element_ = Element
@usableFromInline
internal var _currentSegment: Span<Element>
@@ -44,7 +46,7 @@ extension RigidDeque where Element: ~Copyable {
}
@_alwaysEmitIntoClient
@_lifetime(copy self)
@_lifetime(&self) // FIXME: This should be `@_lifetime(copy self)`
@_lifetime(self: copy self)
public mutating func nextSpan_(maximumCount: Int) -> Span<Element> {
let result = _currentSegment._trim(first: maximumCount)
@@ -77,6 +77,8 @@ package struct _StaccatoParameters {
@available(SwiftStdlib 5.0, *)
public struct _StaccatoBorrowingIterator<Element: ~Copyable>: BorrowingIteratorProtocol_, ~Escapable {
public typealias Element_ = Element
internal let _contents: Span<Element>
internal let _params: _StaccatoParameters
internal var _offset: Int
@@ -88,7 +90,7 @@ public struct _StaccatoBorrowingIterator<Element: ~Copyable>: BorrowingIteratorP
self._offset = 0
}
@_lifetime(copy self)
@_lifetime(&self) // FIXME: Should be `@_lifetime(copy self)`
public mutating func nextSpan_(maximumCount: Int) -> Span<Element> {
let endOffset = _params.endOffset(fromOffset: _offset, maximumCount: maximumCount)
let startOffset = _offset