]> git.lizzy.rs Git - rust.git/blob - tests/ui/variance/variance-covariant-arg-trait-match.rs
Add regression test for #42114
[rust.git] / tests / ui / variance / variance-covariant-arg-trait-match.rs
1 #![allow(dead_code)]
2
3 // Test that even when `T` is only used in covariant position, it
4 // is treated as invariant.
5
6 trait Get<T> {
7     fn get(&self) -> T;
8 }
9
10 fn get_min_from_max<'min, 'max, G>()
11     where 'max : 'min, G : Get<&'max i32>
12 {
13     // Previously OK, now an error as traits are invariant.
14     impls_get::<G,&'min i32>()
15     //~^ ERROR lifetime may not live long enough
16 }
17
18 fn get_max_from_min<'min, 'max, G>()
19     where 'max : 'min, G : Get<&'min i32>
20 {
21     impls_get::<G,&'max i32>()
22     //~^ ERROR lifetime may not live long enough
23 }
24
25 fn impls_get<G,T>() where G : Get<T> { }
26
27 fn main() { }