Skip to content

Commit 671e70d

Browse files
authored
Merge pull request #67000 from gottesmm/pr-6cee72877d2d949635e5ecbf989db6f1ab96a6d9
[move-only] Add some tests around address only lets.
2 parents e417c15 + 840a1c7 commit 671e70d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/SILOptimizer/moveonly_addresschecker_diagnostics.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,41 @@ public func addressOnlyGenericBorrowingConsumeGrandField<T>(_ x: borrowing Addre
24952495
let _ = x.moveOnly.k // expected-note {{consumed here}}
24962496
}
24972497

2498+
public func addressOnlyGenericLetAccessFieldTest<T>(_ x: consuming AddressOnlyGeneric<T>) {
2499+
let x2 = x
2500+
2501+
let _ = x2.moveOnly
2502+
}
2503+
2504+
public func addressOnlyGenericLetAccessFieldTest2<T>(_ x: consuming AddressOnlyGeneric<T>) {
2505+
let x2 = x // expected-error {{'x2' consumed more than once}}
2506+
2507+
let _ = x2.moveOnly // expected-note {{consumed here}}
2508+
let _ = x2.moveOnly // expected-note {{consumed again here}}
2509+
}
2510+
2511+
public func addressOnlyGenericLetAccessFieldTest2a<T>(_ x: consuming AddressOnlyGeneric<T>) {
2512+
let x2 = x // expected-error {{'x2' consumed more than once}}
2513+
2514+
let _ = x2.moveOnly // expected-note {{consumed here}}
2515+
let _ = x2.moveOnly.k // expected-note {{consumed again here}}
2516+
}
2517+
2518+
public func addressOnlyGenericLetAccessFieldTest2b<T>(_ x: consuming AddressOnlyGeneric<T>) {
2519+
let x2 = x // expected-error {{'x2' consumed more than once}}
2520+
2521+
let _ = x2.moveOnly // expected-note {{consumed here}}
2522+
let _ = x2.copyable
2523+
let _ = x2.moveOnly.k // expected-note {{consumed again here}}
2524+
}
2525+
2526+
public func addressOnlyGenericLetAccessFieldTest3<T>(_ x: consuming AddressOnlyGeneric<T>) {
2527+
let x2 = x
2528+
2529+
let _ = x2.moveOnly
2530+
let _ = x2.copyable
2531+
}
2532+
24982533
extension AddressOnlyGeneric {
24992534
func testNoUseSelf() { // expected-error {{'self' is borrowed and cannot be consumed}}
25002535
let x = self // expected-note {{consumed here}}

0 commit comments

Comments
 (0)