mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer This adds a "mutating" initialize to UnsafePointer to make Immutable -> Mutable conversions explicit. These are quick fixes to stdlib, overlays, and test cases that are necessary in order to remove arbitrary UnsafePointer conversions. Many cases can be expressed better up by reworking the surrounding code, but we first need a working starting point.
This commit is contained in:
@@ -204,7 +204,9 @@ NSStringAPIs.test("init(utf8String:)") {
|
||||
i += 1
|
||||
}
|
||||
up[i] = 0
|
||||
expectOptionalEqual(s, String(utf8String: UnsafePointer(up)))
|
||||
let cstr = UnsafeMutableRawPointer(up)
|
||||
.bindMemory(to: CChar.self, capacity: 100)
|
||||
expectOptionalEqual(s, String(utf8String: cstr))
|
||||
up.deallocate(capacity: 100)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user