@@ -36,7 +36,7 @@ public struct MutableSpan<Element: ~Copyable>
36
36
_unchecked start: UnsafeMutableRawPointer ? ,
37
37
count: Int
38
38
) {
39
- _pointer = unsafe start
39
+ unsafe _pointer = start
40
40
_count = count
41
41
}
42
42
}
@@ -54,7 +54,7 @@ extension MutableSpan where Element: ~Copyable {
54
54
internal init(
55
55
_unchecked elements: UnsafeMutableBufferPointer < Element >
56
56
) {
57
- _pointer = . init( elements. baseAddress)
57
+ unsafe _pointer = . init ( elements. baseAddress)
58
58
_count = elements. count
59
59
}
60
60
@@ -190,7 +190,7 @@ extension RawSpan {
190
190
public init < Element: BitwiseCopyable > (
191
191
_mutableSpan mutableSpan: borrowing MutableSpan < Element >
192
192
) {
193
- let pointer = mutableSpan. _pointer
193
+ let pointer = unsafe mutableSpan. _pointer
194
194
let byteCount = mutableSpan. count &* MemoryLayout< Element> . stride
195
195
let buffer = unsafe UnsafeRawBufferPointer( start: pointer, count: byteCount)
196
196
let rawSpan = unsafe RawSpan( _unsafeBytes: buffer)
@@ -203,7 +203,7 @@ extension MutableSpan where Element: ~Copyable {
203
203
204
204
@_alwaysEmitIntoClient
205
205
public var _description : String {
206
- let addr = String (
206
+ let addr = unsafe String(
207
207
UInt ( bitPattern: _pointer) , radix: 16 , uppercase: false
208
208
)
209
209
return " (0x \( addr) , \( _count) ) "
@@ -376,7 +376,7 @@ extension MutableSpan where Element: ~Copyable {
376
376
public func withUnsafeBufferPointer< E: Error , Result: ~ Copyable> (
377
377
_ body: ( _ buffer: UnsafeBufferPointer < Element > ) throws ( E ) -> Result
378
378
) throws ( E ) -> Result {
379
- try Span( _mutableSpan: self ) . withUnsafeBufferPointer( body)
379
+ try unsafe Span( _mutableSpan: self ) . withUnsafeBufferPointer( body)
380
380
}
381
381
382
382
//FIXME: mark closure parameter as non-escaping
@@ -387,7 +387,7 @@ extension MutableSpan where Element: ~Copyable {
387
387
> (
388
388
_ body: ( UnsafeMutableBufferPointer < Element > ) throws ( E ) -> Result
389
389
) throws ( E ) -> Result {
390
- guard let pointer = _pointer, count > 0 else {
390
+ guard let pointer = unsafe _pointer, count > 0 else {
391
391
return try unsafe body( . init( start: nil , count: 0 ) )
392
392
}
393
393
// bind memory by hand to sidestep alignment concerns
@@ -407,7 +407,7 @@ extension MutableSpan where Element: BitwiseCopyable {
407
407
public func withUnsafeBytes< E: Error, Result: ~ Copyable> (
408
408
_ body: ( _ buffer: UnsafeRawBufferPointer ) throws ( E ) -> Result
409
409
) throws ( E ) -> Result {
410
- try RawSpan( _mutableSpan: self ) . withUnsafeBytes( body )
410
+ try unsafe RawSpan( _mutableSpan: self ) . withUnsafeBytes( body )
411
411
}
412
412
413
413
//FIXME: mark closure parameter as non-escaping
@@ -494,7 +494,7 @@ extension MutableSpan {
494
494
unsafe _start( ) . withMemoryRebound (
495
495
to: Element . self, capacity: source. count
496
496
) { dest in
497
- source. withUnsafeBufferPointer {
497
+ unsafe source. withUnsafeBufferPointer {
498
498
unsafe dest. update ( from: $0. baseAddress!, count: $0. count)
499
499
}
500
500
}
@@ -537,7 +537,7 @@ extension MutableSpan where Element: ~Copyable {
537
537
) -> Index {
538
538
// let source = OutputSpan(_initializing: source, initialized: source.count)
539
539
// return self.moveUpdate(fromContentsOf: source)
540
- withUnsafeMutableBufferPointer {
540
+ unsafe withUnsafeMutableBufferPointer {
541
541
unsafe $0. moveUpdate ( fromContentsOf: source)
542
542
}
543
543
}
@@ -551,7 +551,7 @@ extension MutableSpan {
551
551
public mutating func moveUpdate(
552
552
fromContentsOf source: Slice < UnsafeMutableBufferPointer < Element > >
553
553
) -> Index {
554
- moveUpdate ( fromContentsOf: unsafe . init ( rebasing: source) )
554
+ unsafe moveUpdate( fromContentsOf: . init( rebasing: source) )
555
555
}
556
556
}
557
557
@@ -565,7 +565,7 @@ extension MutableSpan where Element: BitwiseCopyable {
565
565
) where Element: BitwiseCopyable {
566
566
guard count > 0 else { return }
567
567
// rebind _start manually in order to avoid assumptions about alignment.
568
- let rp = _start ( ) . _rawValue
568
+ let rp = unsafe _start( ) . _rawValue
569
569
let binding = Builtin . bindMemory ( rp, count. _builtinWordValue, Element . self)
570
570
let rebound = unsafe UnsafeMutablePointer< Element > ( rp)
571
571
unsafe rebound. update ( repeating: repeatedValue, count: count)
@@ -630,7 +630,7 @@ extension MutableSpan where Element: BitwiseCopyable {
630
630
source. count <= self . count,
631
631
" destination span cannot contain every element from source. "
632
632
)
633
- source. withUnsafeBufferPointer {
633
+ unsafe source. withUnsafeBufferPointer {
634
634
unsafe _start( ) . copyMemory (
635
635
from: $0. baseAddress!,
636
636
byteCount: $0. count &* MemoryLayout< Element> . stride
0 commit comments