[Strict memory safety] Remove now-extraneous "unsafe" from the standard libraries

Now that we aren't propagating "unsafe" to nested types, remove
unnecessary "unsafe" keywords from the standard library.

(cherry picked from commit fe6856726e)
This commit is contained in:
Doug Gregor
2025-04-19 08:13:05 -07:00
parent 4c5ba0c5cb
commit 469b30334c
8 changed files with 49 additions and 49 deletions

View File

@@ -160,11 +160,11 @@ internal func validateUTF8(_ buf: UnsafeBufferPointer<UInt8>) -> UTF8ValidationR
func _legacyNarrowIllegalRange(buf: Slice<UnsafeBufferPointer<UInt8>>) -> Range<Int> {
var reversePacked: UInt32 = 0
if let third = unsafe buf.dropFirst(2).first {
unsafe reversePacked |= UInt32(third)
reversePacked |= UInt32(third)
reversePacked <<= 8
}
if let second = unsafe buf.dropFirst().first {
unsafe reversePacked |= UInt32(second)
reversePacked |= UInt32(second)
reversePacked <<= 8
}
unsafe reversePacked |= UInt32(buf.first!)
@@ -177,8 +177,8 @@ internal func validateUTF8(_ buf: UnsafeBufferPointer<UInt8>) -> UTF8ValidationR
var endIndex = unsafe buf.startIndex
var iter = unsafe buf.makeIterator()
_ = unsafe iter.next()
while let cu = unsafe iter.next(), unsafe UTF8.isContinuation(cu) {
unsafe endIndex += 1
while let cu = unsafe iter.next(), UTF8.isContinuation(cu) {
endIndex += 1
// Unicode's Maximal subpart of an ill-formed subsequence will yield
// at most 3 bytes of error.
if unsafe buf.distance(from: buf.startIndex, to: endIndex) >= 3 {