2015-02-12 04:16:02 -06:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2015-04-01 03:41:45 -05:00
|
|
|
// Test that even when `T` is only used in contravariant position, it
|
|
|
|
// is treated as invariant.
|
|
|
|
|
2015-02-12 04:16:02 -06:00
|
|
|
trait Get<T> {
|
|
|
|
fn get(&self, t: T);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_min_from_max<'min, 'max, G>()
|
|
|
|
where 'max : 'min, G : Get<&'max i32>
|
|
|
|
{
|
2022-04-01 21:12:17 -05:00
|
|
|
impls_get::<G,&'min i32>()
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-02-12 04:16:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn get_max_from_min<'min, 'max, G>()
|
|
|
|
where 'max : 'min, G : Get<&'min i32>
|
|
|
|
{
|
2015-03-31 18:58:01 -05:00
|
|
|
// Previously OK, but now an error because traits are invariant:
|
|
|
|
|
2022-04-01 21:12:17 -05:00
|
|
|
impls_get::<G,&'max i32>()
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-02-12 04:16:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn impls_get<G,T>() where G : Get<T> { }
|
|
|
|
|
|
|
|
fn main() { }
|