]> git.lizzy.rs Git - rust.git/blob - tests/ui/variance/variance-contravariant-self-trait-match.rs
Auto merge of #106458 - albertlarsan68:move-tests, r=jyn514
[rust.git] / tests / ui / variance / variance-contravariant-self-trait-match.rs
1 #![allow(dead_code)]
2
3 // Test that even when `Self` is only used in contravariant position, it
4 // is treated as invariant.
5
6 trait Get {
7     fn get(&self);
8 }
9
10 fn get_min_from_max<'min, 'max, G>()
11     where 'max : 'min, G : 'max, &'max G : Get
12 {
13     impls_get::<&'min G>();
14     //~^ ERROR lifetime may not live long enough
15 }
16
17 fn get_max_from_min<'min, 'max, G>()
18     where 'max : 'min, G : 'max, &'min G : Get
19 {
20     // Previously OK, but now error because traits are invariant with
21     // respect to all inputs.
22
23     impls_get::<&'max G>();
24     //~^ ERROR lifetime may not live long enough
25 }
26
27 fn impls_get<G>() where G : Get { }
28
29 fn main() { }