mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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:
@@ -27,13 +27,21 @@ public struct Unsafe${Mutable}RawPointer : Strideable, Hashable, _Pointer {
|
||||
/// Implements conformance to the public protocol `_Pointer`.
|
||||
public let _rawValue: Builtin.RawPointer
|
||||
|
||||
// Construct ${a_Self} from another ${a_Self}.
|
||||
// FIXME: Why is this necessary?
|
||||
/// Construct ${a_Self} from another ${a_Self}.
|
||||
@_transparent
|
||||
public init(_ other: Unsafe${Mutable}RawPointer) {
|
||||
self = other
|
||||
}
|
||||
|
||||
/// Construct ${a_Self} from another ${a_Self}.
|
||||
///
|
||||
/// Returns nil if `other` is nil.
|
||||
@_transparent
|
||||
public init?(_ other: Unsafe${Mutable}RawPointer?) {
|
||||
guard let unwrapped = other else { return nil }
|
||||
self = unwrapped
|
||||
}
|
||||
|
||||
/// Convert a builtin raw pointer to ${a_Self}.
|
||||
@_transparent
|
||||
public init(_ _rawValue: Builtin.RawPointer) {
|
||||
|
||||
Reference in New Issue
Block a user