File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -711,7 +711,8 @@ extension RawSpan {
711
711
public func _extracting( first maxLength: Int ) -> Self {
712
712
_precondition ( maxLength >= 0 , " Can't have a prefix of negative length " )
713
713
let newCount = min ( maxLength, byteCount)
714
- return unsafe Self( _unchecked: _pointer, byteCount: newCount)
714
+ let newSpan = unsafe Self( _unchecked: _pointer, byteCount: newCount)
715
+ return unsafe _override Lifetime ( newSpan, copying: self )
715
716
}
716
717
717
718
/// Returns a span over all but the given number of trailing bytes.
@@ -734,7 +735,8 @@ extension RawSpan {
734
735
_precondition ( k >= 0 , " Can't drop a negative number of bytes " )
735
736
let droppedCount = min ( k, byteCount)
736
737
let count = byteCount &- droppedCount
737
- return unsafe Self( _unchecked: _pointer, byteCount: count)
738
+ let newSpan = unsafe Self( _unchecked: _pointer, byteCount: count)
739
+ return unsafe _override Lifetime ( newSpan, copying: self )
738
740
}
739
741
740
742
/// Returns a span containing the trailing bytes of the span,
Original file line number Diff line number Diff line change @@ -764,7 +764,8 @@ extension Span where Element: ~Copyable {
764
764
public func _extracting( first maxLength: Int ) -> Self {
765
765
_precondition ( maxLength >= 0 , " Can't have a prefix of negative length " )
766
766
let newCount = min ( maxLength, count)
767
- return unsafe Self( _unchecked: _pointer, count: newCount)
767
+ let newSpan = unsafe Self( _unchecked: _pointer, count: newCount)
768
+ return unsafe _override Lifetime ( newSpan, copying: self )
768
769
}
769
770
770
771
/// Returns a span over all but the given number of trailing elements.
@@ -786,7 +787,8 @@ extension Span where Element: ~Copyable {
786
787
public func _extracting( droppingLast k: Int ) -> Self {
787
788
_precondition ( k >= 0 , " Can't drop a negative number of elements " )
788
789
let droppedCount = min ( k, count)
789
- return unsafe Self( _unchecked: _pointer, count: count &- droppedCount)
790
+ let newSpan = unsafe Self( _unchecked: _pointer, count: count &- droppedCount)
791
+ return unsafe _override Lifetime ( newSpan, copying: self )
790
792
}
791
793
792
794
/// Returns a span containing the final elements of the span,
Original file line number Diff line number Diff line change @@ -181,7 +181,8 @@ extension UTF8Span {
181
181
public var span : Span < UInt8 > {
182
182
@lifetime ( copy self)
183
183
get {
184
- unsafe Span( _unchecked: _unsafeBaseAddress, count: self . count)
184
+ let newSpan = unsafe Span< UInt8 > ( _unchecked: _unsafeBaseAddress, count: self . count)
185
+ return unsafe _override Lifetime ( newSpan, copying: self )
185
186
}
186
187
}
187
188
You can’t perform that action at this time.
0 commit comments