|
| 1 | +// RUN: %target-swift-emit-sil %s -verify -sil-verify-all |
| 2 | + |
| 3 | +struct Point { |
| 4 | + let x: Float |
| 5 | + let y: Float |
| 6 | +} |
| 7 | + |
| 8 | +struct ConditionallyBC<T> { |
| 9 | + var t: T |
| 10 | +} |
| 11 | +extension ConditionallyBC: BitwiseCopyable where T: BitwiseCopyable {} |
| 12 | + |
| 13 | +func test<T, BCG: BitwiseCopyable>(_ t: T, // expected-error {{'t' is borrowed and cannot be consumed}} |
| 14 | + _ bcg: BCG, // expected-error {{'bcg' is borrowed and cannot be consumed}} |
| 15 | + _ cbcg_generic: ConditionallyBC<BCG>, // expected-error {{'cbcg_generic' is borrowed and cannot be consumed}} |
| 16 | + _ maybeBCG: BCG?, // expected-error {{'maybeBCG' is borrowed and cannot be consumed}} |
| 17 | + _ maybeT: T?, // expected-error {{'maybeT' is borrowed and cannot be consumed}} |
| 18 | + _ anyBC: any BitwiseCopyable, // expected-error {{'anyBC' is borrowed and cannot be consumed}} |
| 19 | + _ x: Int, |
| 20 | + _ point: Point, |
| 21 | + _ cbcg_concrete: ConditionallyBC<Int>, |
| 22 | + _ maybeFloat: Float?) { |
| 23 | + _ = consume t // expected-note {{consumed here}} |
| 24 | + _ = consume bcg // expected-note {{consumed here}} |
| 25 | + _ = consume cbcg_generic // expected-note {{consumed here}} |
| 26 | + _ = consume maybeBCG // expected-note {{consumed here}} |
| 27 | + _ = consume maybeT // expected-note {{consumed here}} |
| 28 | + _ = consume anyBC // expected-note {{consumed here}} |
| 29 | + |
| 30 | + _ = consume x // expected-warning {{'consume' applied to bitwise-copyable type 'Int' has no effect currently, but will in the future}}{{7-15=}} |
| 31 | + _ = consume point // expected-warning {{'consume' applied to bitwise-copyable type 'Point' has no effect currently, but will in the future}}{{7-15=}} |
| 32 | + _ = consume cbcg_concrete // expected-warning {{'consume' applied to bitwise-copyable type 'ConditionallyBC<Int>' has no effect currently, but will in the future}}{{7-16=}} |
| 33 | + _ = consume maybeFloat // expected-warning {{'consume' applied to bitwise-copyable type 'Float?' has no effect currently, but will in the future}}{{8-16=}} |
| 34 | +} |
0 commit comments