Skip to content

Commit 60e66f3

Browse files
committed
stdlib: Address StrictMemorySafety warnings in String related code.
1 parent b3038e6 commit 60e66f3

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

stdlib/public/core/StringCreate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ extension String {
383383
}
384384

385385
let storage = unsafe buffer.baseAddress.map {
386-
__SharedStringStorage(
386+
unsafe __SharedStringStorage(
387387
_mortal: $0,
388388
countAndFlags: _StringObject.CountAndFlags(
389389
count: buffer.startIndex.distance(to: written),

stdlib/public/core/StringGuts.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ extension _StringGuts {
236236
_ body: (UnsafePointer<Int8>) throws -> Result
237237
) rethrows -> Result {
238238
_internalInvariant(!_object.isFastZeroTerminated)
239-
return try String(self).utf8CString.withUnsafeBufferPointer {
239+
return try unsafe String(self).utf8CString.withUnsafeBufferPointer {
240240
let ptr = unsafe $0.baseAddress._unsafelyUnwrappedUnchecked
241241
return try unsafe body(ptr)
242242
}

stdlib/public/core/StringObject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ extension _StringObject {
982982
}
983983
}
984984
#endif
985-
return unsafe withSharedStorage { $0.start }
985+
return unsafe withSharedStorage { unsafe $0.start }
986986
}
987987

988988
@usableFromInline

stdlib/public/core/StringStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ final internal class __SharedStringStorage
699699
countAndFlags: _StringObject.CountAndFlags
700700
) {
701701
self._owner = nil
702-
self.start = unsafe ptr
702+
unsafe self.start = ptr
703703
self.immortal = true
704704
#if _pointerBitWidth(_64)
705705
self._countAndFlags = countAndFlags
@@ -728,7 +728,7 @@ final internal class __SharedStringStorage
728728
) {
729729
// ptr *must* be the start of an allocation
730730
self._owner = nil
731-
self.start = unsafe ptr
731+
unsafe self.start = ptr
732732
self.immortal = false
733733
#if _pointerBitWidth(_64)
734734
self._countAndFlags = countAndFlags

stdlib/public/core/StringStorageBridge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ extension __SharedStringStorage {
312312
@objc(UTF8String)
313313
@_effects(readonly)
314314
final internal func _utf8String() -> UnsafePointer<UInt8>? {
315-
return start
315+
return unsafe start
316316
}
317317

318318
@objc(cStringUsingEncoding:)

stdlib/public/core/StringUTF8View.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ extension String {
278278
@_effects(readonly) @_semantics("string.getUTF8CString")
279279
get {
280280
if _fastPath(_guts.isFastUTF8) {
281-
var result = unsafe _guts.withFastCChar { ContiguousArray($0) }
281+
var result = unsafe _guts.withFastCChar { unsafe ContiguousArray($0) }
282282
result.append(0)
283283
return result
284284
}

0 commit comments

Comments
 (0)