Skip to content

[move-only] Add some tests around address only lets. #67000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/SILOptimizer/moveonly_addresschecker_diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,41 @@ public func addressOnlyGenericBorrowingConsumeGrandField<T>(_ x: borrowing Addre
let _ = x.moveOnly.k // expected-note {{consumed here}}
}

public func addressOnlyGenericLetAccessFieldTest<T>(_ x: consuming AddressOnlyGeneric<T>) {
let x2 = x

let _ = x2.moveOnly
}

public func addressOnlyGenericLetAccessFieldTest2<T>(_ x: consuming AddressOnlyGeneric<T>) {
let x2 = x // expected-error {{'x2' consumed more than once}}

let _ = x2.moveOnly // expected-note {{consumed here}}
let _ = x2.moveOnly // expected-note {{consumed again here}}
}

public func addressOnlyGenericLetAccessFieldTest2a<T>(_ x: consuming AddressOnlyGeneric<T>) {
let x2 = x // expected-error {{'x2' consumed more than once}}

let _ = x2.moveOnly // expected-note {{consumed here}}
let _ = x2.moveOnly.k // expected-note {{consumed again here}}
}

public func addressOnlyGenericLetAccessFieldTest2b<T>(_ x: consuming AddressOnlyGeneric<T>) {
let x2 = x // expected-error {{'x2' consumed more than once}}

let _ = x2.moveOnly // expected-note {{consumed here}}
let _ = x2.copyable
let _ = x2.moveOnly.k // expected-note {{consumed again here}}
}

public func addressOnlyGenericLetAccessFieldTest3<T>(_ x: consuming AddressOnlyGeneric<T>) {
let x2 = x

let _ = x2.moveOnly
let _ = x2.copyable
}

extension AddressOnlyGeneric {
func testNoUseSelf() { // expected-error {{'self' is borrowed and cannot be consumed}}
let x = self // expected-note {{consumed here}}
Expand Down