]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-use-invariant-struct-1.rs
Auto merge of #100845 - timvermeulen:iter_compare, r=scottmcm
[rust.git] / src / test / ui / variance / variance-use-invariant-struct-1.rs
1 // Test various uses of structs with distinct variances to make sure
2 // they permit lifetimes to be approximated as expected.
3
4 struct SomeStruct<T>(*mut T);
5
6 fn foo<'min,'max>(v: SomeStruct<&'max ()>)
7                   -> SomeStruct<&'min ()>
8     where 'max : 'min
9 {
10     v
11     //~^ ERROR lifetime may not live long enough
12 }
13
14 fn bar<'min,'max>(v: SomeStruct<&'min ()>)
15                   -> SomeStruct<&'max ()>
16     where 'max : 'min
17 {
18     v
19     //~^ ERROR lifetime may not live long enough
20 }
21
22
23 fn main() { }