2022-08-18 10:13:37 +08:00
|
|
|
// Test various uses of structs with distinct variances to make sure
|
2015-02-12 05:16:02 -05:00
|
|
|
// they permit lifetimes to be approximated as expected.
|
|
|
|
|
|
|
|
struct SomeStruct<T>(*mut T);
|
|
|
|
|
|
|
|
fn foo<'min,'max>(v: SomeStruct<&'max ()>)
|
|
|
|
-> SomeStruct<&'min ()>
|
|
|
|
where 'max : 'min
|
|
|
|
{
|
2022-04-01 22:12:17 -04:00
|
|
|
v
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-02-12 05:16:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bar<'min,'max>(v: SomeStruct<&'min ()>)
|
|
|
|
-> SomeStruct<&'max ()>
|
|
|
|
where 'max : 'min
|
|
|
|
{
|
2022-04-01 22:12:17 -04:00
|
|
|
v
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2015-02-12 05:16:02 -05:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:18:11 +01:00
|
|
|
|
2015-02-12 05:16:02 -05:00
|
|
|
fn main() { }
|