mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Strict memory safety] Treat the implicit call to a 'defer' function as implicitly 'unsafe'
This eliminates stray warnings.
This commit is contained in:
@@ -293,3 +293,18 @@ struct UnsafeContainingUnspecified {
|
||||
let a = unsafe x.getA()
|
||||
_ = a
|
||||
}
|
||||
|
||||
extension Slice {
|
||||
// Make sure we aren't diagnosing the 'defer' as unsafe.
|
||||
public func withContiguousMutableStorageIfAvailable<R, Element>(
|
||||
_ body: (_ buffer: inout UnsafeMutableBufferPointer<Element>) throws -> R
|
||||
) rethrows -> R? where Base == UnsafeMutableBufferPointer<Element> {
|
||||
try unsafe base.withContiguousStorageIfAvailable { buffer in
|
||||
let start = unsafe base.baseAddress?.advanced(by: startIndex)
|
||||
var slice = unsafe UnsafeMutableBufferPointer(start: start, count: count)
|
||||
defer {
|
||||
}
|
||||
return try unsafe body(&slice)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user