]>
Commit | Line | Data |
---|---|---|
85aaf69f | 1 | #![allow(dead_code)] |
223e47cc | 2 | |
9346a6ac AL |
3 | // Test that even when `T` is only used in contravariant position, it |
4 | // is treated as invariant. | |
5 | ||
85aaf69f SL |
6 | trait Get<T> { |
7 | fn get(&self, t: T); | |
8 | } | |
1a4d82fc | 9 | |
85aaf69f SL |
10 | fn get_min_from_max<'min, 'max, G>() |
11 | where 'max : 'min, G : Get<&'max i32> | |
12 | { | |
04454e1e | 13 | impls_get::<G,&'min i32>() |
923072b8 | 14 | //~^ ERROR lifetime may not live long enough |
85aaf69f SL |
15 | } |
16 | ||
17 | fn get_max_from_min<'min, 'max, G>() | |
18 | where 'max : 'min, G : Get<&'min i32> | |
19 | { | |
9346a6ac AL |
20 | // Previously OK, but now an error because traits are invariant: |
21 | ||
04454e1e | 22 | impls_get::<G,&'max i32>() |
923072b8 | 23 | //~^ ERROR lifetime may not live long enough |
85aaf69f SL |
24 | } |
25 | ||
26 | fn impls_get<G,T>() where G : Get<T> { } | |
223e47cc LB |
27 | |
28 | fn main() { } |