Skip to content

Commit 20a29fe

Browse files
committed
[gardening] 80-column vigilance
1 parent ff1296c commit 20a29fe

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
@@ -285,7 +285,9 @@ extension Span where Element: BitwiseCopyable {
285285
byteCount: Int
286286
) {
287287
_precondition(byteCount >= 0, "Count must not be negative")
288-
let rawBuffer = unsafe UnsafeRawBufferPointer(start: pointer, count: byteCount)
288+
let rawBuffer = unsafe UnsafeRawBufferPointer(
289+
start: pointer, count: byteCount
290+
)
289291
let span = Span(_unsafeBytes: rawBuffer)
290292
// As a trivial value, 'rawBuffer' does not formally depend on the
291293
// lifetime of 'pointer'. Make the dependence explicit.
@@ -348,8 +350,9 @@ extension Span where Element: BitwiseCopyable {
348350
@_alwaysEmitIntoClient
349351
@lifetime(bytes)
350352
public init(_bytes bytes: consuming RawSpan) {
351-
let rawBuffer =
352-
unsafe UnsafeRawBufferPointer(start: bytes._pointer, count: bytes.byteCount)
353+
let rawBuffer = unsafe UnsafeRawBufferPointer(
354+
start: bytes._pointer, count: bytes.byteCount
355+
)
353356
let span = Span(_unsafeBytes: rawBuffer)
354357
// As a trivial value, 'rawBuffer' does not formally depend on the
355358
// lifetime of 'bytes'. Make the dependence explicit.
@@ -683,12 +686,14 @@ extension Span where Element: ~Copyable {
683686
public func indices(of other: borrowing Self) -> Range<Index>? {
684687
if other._count > _count { return nil }
685688
guard let spanStart = other._pointer, _count > 0 else {
686-
return unsafe _pointer == other._pointer ? Range(_uncheckedBounds: (0, 0)) : nil
689+
return unsafe _pointer == other._pointer ? 0..<0 : nil
687690
}
688691
let start = _start()
689692
let stride = MemoryLayout<Element>.stride
690693
let spanEnd = unsafe spanStart + stride &* other._count
691-
if unsafe spanStart < start || spanEnd > (start + stride &* _count) { return nil }
694+
if unsafe spanStart < start || spanEnd > (start + stride &* _count) {
695+
return nil
696+
}
692697
let byteOffset = unsafe start.distance(to: spanStart)
693698
let (lower, r) = byteOffset.quotientAndRemainder(dividingBy: stride)
694699
guard r == 0 else { return nil }

0 commit comments

Comments
 (0)