mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SILGen inserts mark_unresolved_noncopyable_value at the introducer in some cases and at uses in other cases. This inconsistency can causes insertion of a redundant mark* instruction which crashes the move-only checker. This change avoids inserting a redundant mark* instruction.
24 lines
756 B
Swift
24 lines
756 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify -enable-experimental-feature AddressableParameters %s
|
|
|
|
// REQUIRES: swift_feature_AddressableParameters
|
|
|
|
public struct Container<Element: ~Copyable >: ~Copyable {
|
|
var _storage: UnsafeMutableBufferPointer<Element>
|
|
var _count: Int
|
|
|
|
public subscript(index: Int) -> Element {
|
|
@_addressableSelf
|
|
_read {
|
|
precondition(index >= 0 && index < _count, "Index out of bounds")
|
|
yield _storage.baseAddress.unsafelyUnwrapped.advanced(by: index).pointee
|
|
}
|
|
_modify {
|
|
precondition(index >= 0 && index < _count, "Index out of bounds")
|
|
yield &_storage.baseAddress.unsafelyUnwrapped.advanced(by: index).pointee
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Container: Copyable where Element: Copyable {}
|
|
|