mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Update tests for strict @lifetime type checking
This commit is contained in:
@@ -10,7 +10,7 @@ internal func _overrideLifetime<T: ~Copyable & ~Escapable, U: ~Copyable & ~Escap
|
||||
@_unsafeNonescapableResult
|
||||
@_alwaysEmitIntoClient
|
||||
@_transparent
|
||||
@lifetime(source)
|
||||
@lifetime(copy source)
|
||||
internal func _overrideLifetime<T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable>(
|
||||
_ dependent: consuming T, copying source: borrowing U) -> T {
|
||||
dependent
|
||||
@@ -43,7 +43,7 @@ public struct BufferView : ~Escapable {
|
||||
self = _overrideLifetime(bv, borrowing: a)
|
||||
}
|
||||
@inlinable
|
||||
@lifetime(a)
|
||||
@lifetime(copy a)
|
||||
internal init(_ ptr: UnsafeRawBufferPointer, _ a: consuming AnotherView) {
|
||||
let bv = BufferView(ptr, a._count)
|
||||
self = _overrideLifetime(bv, copying: a)
|
||||
@@ -51,7 +51,7 @@ public struct BufferView : ~Escapable {
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@lifetime(x)
|
||||
@lifetime(copy x)
|
||||
public func derive(_ x: consuming BufferView) -> BufferView {
|
||||
let pointer = x._ptr
|
||||
let bv = BufferView(pointer, x._count)
|
||||
@@ -62,7 +62,7 @@ public func derive(_ x: consuming BufferView) -> BufferView {
|
||||
public func use(_ x: consuming BufferView) {}
|
||||
|
||||
@inlinable
|
||||
@lifetime(view)
|
||||
@lifetime(copy view)
|
||||
public func consumeAndCreate(_ view: consuming BufferView) -> BufferView {
|
||||
let pointer = view._ptr
|
||||
let bv = BufferView(pointer, view._count)
|
||||
@@ -70,7 +70,7 @@ public func consumeAndCreate(_ view: consuming BufferView) -> BufferView {
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@lifetime(this, that)
|
||||
@lifetime(copy this, copy that)
|
||||
public func deriveThisOrThat(_ this: consuming BufferView, _ that: consuming BufferView) -> BufferView {
|
||||
if (Int.random(in: 1..<100) == 0) {
|
||||
return BufferView(this._ptr, this._count)
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
import lifetime_dependence
|
||||
// CHECK: @lifetime(borrow a)
|
||||
// CHECK-NEXT: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: borrowing Swift.Array<Swift.Int>) {
|
||||
// CHECK: @lifetime(a)
|
||||
// CHECK: @lifetime(copy a)
|
||||
// CHECK-NEXT: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: consuming lifetime_dependence.AnotherView) {
|
||||
|
||||
// CHECK: @lifetime(x)
|
||||
// CHECK: @lifetime(copy x)
|
||||
// CHECK-NEXT: @inlinable public func derive(_ x: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {
|
||||
|
||||
// CHECK: @lifetime(view)
|
||||
// CHECK: @lifetime(copy view)
|
||||
// CHECK-NEXT: @inlinable public func consumeAndCreate(_ view: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {
|
||||
|
||||
// CHECK: @lifetime(this, that)
|
||||
// CHECK: @lifetime(copy this, copy that)
|
||||
// CHECK-NEXT: @inlinable public func deriveThisOrThat(_ this: consuming lifetime_dependence.BufferView, _ that: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {
|
||||
|
||||
// Check that an implicitly dependent variable accessor is guarded by LifetimeDependence.
|
||||
|
||||
@@ -50,19 +50,19 @@ public enum Y<T: ~Escapable>: ~Escapable {
|
||||
extension Y: Escapable where T: Escapable { }
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $NonescapableTypes
|
||||
// CHECK: @lifetime(y)
|
||||
// CHECK: @lifetime(copy y)
|
||||
// CHECK: public func derive<T>(_ y: Test.Y<T>) -> Test.Y<T> where T : ~Escapable
|
||||
// CHECK: #endif
|
||||
@lifetime(y)
|
||||
@lifetime(copy y)
|
||||
public func derive<T : ~Escapable>(_ y: Y<T>) -> Y<T> {
|
||||
y
|
||||
}
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $NonescapableTypes
|
||||
// CHECK: @lifetime(x)
|
||||
// CHECK: @lifetime(copy x)
|
||||
// CHECK: public func derive<T>(_ x: Test.X<T>) -> Test.X<T> where T : ~Escapable
|
||||
// CHECK: #endif
|
||||
@lifetime(x)
|
||||
@lifetime(copy x)
|
||||
public func derive<T : ~Escapable>(_ x: X<T>) -> X<T> {
|
||||
x
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user