Skip to content

Commit 712c79c

Browse files
committed
[gardening] 80-column vigilance
1 parent b70f0f6 commit 712c79c

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

stdlib/public/core/Span/RawSpan.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ extension RawSpan {
150150
public init(
151151
_unsafeBytes buffer: borrowing Slice<UnsafeMutableRawBufferPointer>
152152
) {
153-
let rawBuffer =
154-
UnsafeRawBufferPointer(unsafe UnsafeMutableRawBufferPointer(rebasing: buffer))
153+
let rawBuffer = UnsafeRawBufferPointer(
154+
unsafe UnsafeMutableRawBufferPointer(rebasing: buffer)
155+
)
155156
let span = RawSpan(_unsafeBytes: rawBuffer)
156157
// As a trivial value, 'rawBuffer' does not formally depend on the
157158
// lifetime of 'buffer'. Make the dependence explicit.
@@ -211,7 +212,7 @@ extension RawSpan {
211212
public init<T: BitwiseCopyable>(
212213
_unsafeElements buffer: borrowing Slice<UnsafeBufferPointer<T>>
213214
) {
214-
let rawBuffer = UnsafeRawBufferPointer(unsafe UnsafeBufferPointer(rebasing: buffer))
215+
let rawBuffer = UnsafeRawBufferPointer(unsafe .init(rebasing: buffer))
215216
let span = RawSpan(_unsafeBytes: rawBuffer)
216217
// As a trivial value, 'rawBuffer' does not formally depend on the
217218
// lifetime of 'buffer'. Make the dependence explicit.
@@ -251,8 +252,9 @@ extension RawSpan {
251252
public init<T: BitwiseCopyable>(
252253
_unsafeElements buffer: borrowing Slice<UnsafeMutableBufferPointer<T>>
253254
) {
254-
let rawBuffer =
255-
UnsafeRawBufferPointer(unsafe UnsafeMutableBufferPointer(rebasing: buffer))
255+
let rawBuffer = UnsafeRawBufferPointer(
256+
unsafe UnsafeMutableBufferPointer(rebasing: buffer)
257+
)
256258
let span = RawSpan(_unsafeBytes: rawBuffer)
257259
// As a trivial value, 'rawBuffer' does not formally depend on the
258260
// lifetime of 'buffer'. Make the dependence explicit.
@@ -593,7 +595,9 @@ extension RawSpan {
593595
MemoryLayout<T>.size <= (_count &- offset),
594596
"Byte offset range out of bounds"
595597
)
596-
return unsafe unsafeLoadUnaligned(fromUncheckedByteOffset: offset, as: T.self)
598+
return unsafe unsafeLoadUnaligned(
599+
fromUncheckedByteOffset: offset, as: T.self
600+
)
597601
}
598602

599603
/// Returns a new instance of the given type, constructed from the raw memory
@@ -643,7 +647,7 @@ extension RawSpan {
643647
public func byteOffsets(of other: borrowing Self) -> Range<Int>? {
644648
if other._count > _count { return nil }
645649
guard let spanStart = other._pointer, _count > 0 else {
646-
return unsafe _pointer == other._pointer ? Range(_uncheckedBounds: (0, 0)) : nil
650+
return unsafe _pointer == other._pointer ? 0..<0 : nil
647651
}
648652
let start = _start()
649653
let spanEnd = unsafe spanStart + other._count

stdlib/public/core/Span/Span.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ extension Span where Element: BitwiseCopyable {
293293
byteCount: Int
294294
) {
295295
_precondition(byteCount >= 0, "Count must not be negative")
296-
let rawBuffer = unsafe UnsafeRawBufferPointer(start: pointer, count: byteCount)
296+
let rawBuffer = unsafe UnsafeRawBufferPointer(
297+
start: pointer, count: byteCount
298+
)
297299
let span = Span(_unsafeBytes: rawBuffer)
298300
// As a trivial value, 'rawBuffer' does not formally depend on the
299301
// lifetime of 'pointer'. Make the dependence explicit.
@@ -358,8 +360,9 @@ extension Span where Element: BitwiseCopyable {
358360
@_alwaysEmitIntoClient
359361
@lifetime(bytes)
360362
public init(_bytes bytes: consuming RawSpan) {
361-
let rawBuffer =
362-
unsafe UnsafeRawBufferPointer(start: bytes._pointer, count: bytes.byteCount)
363+
let rawBuffer = unsafe UnsafeRawBufferPointer(
364+
start: bytes._pointer, count: bytes.byteCount
365+
)
363366
let span = Span(_unsafeBytes: rawBuffer)
364367
// As a trivial value, 'rawBuffer' does not formally depend on the
365368
// lifetime of 'bytes'. Make the dependence explicit.
@@ -696,12 +699,14 @@ extension Span where Element: ~Copyable {
696699
public func indices(of other: borrowing Self) -> Range<Index>? {
697700
if other._count > _count { return nil }
698701
guard let spanStart = other._pointer, _count > 0 else {
699-
return unsafe _pointer == other._pointer ? Range(_uncheckedBounds: (0, 0)) : nil
702+
return unsafe _pointer == other._pointer ? 0..<0 : nil
700703
}
701704
let start = _start()
702705
let stride = MemoryLayout<Element>.stride
703706
let spanEnd = unsafe spanStart + stride &* other._count
704-
if unsafe spanStart < start || spanEnd > (start + stride &* _count) { return nil }
707+
if unsafe spanStart < start || spanEnd > (start + stride &* _count) {
708+
return nil
709+
}
705710
let byteOffset = unsafe start.distance(to: spanStart)
706711
let (lower, r) = byteOffset.quotientAndRemainder(dividingBy: stride)
707712
guard r == 0 else { return nil }

0 commit comments

Comments
 (0)