Skip to content

Commit b068a4c

Browse files
committed
add test for warnings emitted when missing consuming attribute
1 parent 0f6a32f commit b068a4c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Concurrency/custom_executor_enqueue_impls.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ final class NewExecutor: SerialExecutor {
5151
UnownedSerialExecutor(ordinary: self)
5252
}
5353
}
54+
55+
// Good impl, but missing the ownership keyword
56+
final class MissingOwnership: SerialExecutor {
57+
func enqueue(_ job: ExecutorJob) {} // expected-error{{noncopyable parameter must specify its ownership}}
58+
// expected-note@-1{{add 'borrowing' for an immutable reference}}
59+
// expected-note@-2{{add 'inout' for a mutable reference}}
60+
// expected-note@-3{{add 'consuming' to take the value from the caller}}
61+
62+
func asUnownedSerialExecutor() -> UnownedSerialExecutor {
63+
UnownedSerialExecutor(ordinary: self)
64+
}
65+
}

0 commit comments

Comments
 (0)