Skip to content

Commit 0922b6b

Browse files
committed
[span] improve argument labels for safe initializers
1 parent 9a8f5a7 commit 0922b6b

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

stdlib/public/core/Span/RawSpan.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,9 @@ extension RawSpan {
274274
/// - span: An existing `Span<T>`, which will define both this
275275
/// `RawSpan`'s lifetime and the memory it represents.
276276
@_disallowFeatureSuppression(NonescapableTypes)
277-
@unsafe // remove when fixing the lifetime annotation
278277
@_alwaysEmitIntoClient
279278
@lifetime(span)
280-
public init<Element: BitwiseCopyable>(
281-
_unsafeSpan span: consuming Span<Element>
282-
) {
279+
public init<Element: BitwiseCopyable>(_elements span: consuming Span<Element>) {
283280
self.init(
284281
_unchecked: span._pointer,
285282
byteCount: span.count &* MemoryLayout<Element>.stride

stdlib/public/core/Span/Span.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ extension Span where Element: BitwiseCopyable {
320320
/// Create a `Span` over the bytes represented by a `RawSpan`
321321
///
322322
/// - Parameters:
323-
/// - rawSpan: An existing `RawSpan`, which will define both this
324-
/// `Span`'s lifetime and the memory it represents.
323+
/// - bytes: An existing `RawSpan`, which will define both this
324+
/// `Span`'s lifetime and the memory it represents.
325325
@_disallowFeatureSuppression(NonescapableTypes)
326326
@_alwaysEmitIntoClient
327-
@lifetime(rawSpan)
328-
public init(_bytes rawSpan: consuming RawSpan) {
327+
@lifetime(bytes)
328+
public init(_bytes bytes: consuming RawSpan) {
329329
self.init(
330-
_unsafeBytes: .init(start: rawSpan._pointer, count: rawSpan.byteCount)
330+
_unsafeBytes: .init(start: bytes._pointer, count: bytes.byteCount)
331331
)
332332
}
333333
}
@@ -712,7 +712,7 @@ extension Span where Element: BitwiseCopyable {
712712
public func withUnsafeBytes<E: Error, Result: ~Copyable>(
713713
_ body: (_ buffer: UnsafeRawBufferPointer) throws(E) -> Result
714714
) throws(E) -> Result {
715-
try RawSpan(_unsafeSpan: self).withUnsafeBytes(body)
715+
try RawSpan(_elements: self).withUnsafeBytes(body)
716716
}
717717
}
718718

0 commit comments

Comments
 (0)