]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-contravariant-self-trait-match.rs
Rollup merge of #93389 - cameron1024:issue-90847-regression, r=Mark-Simulacrum
[rust.git] / src / test / 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>(); //~ ERROR mismatched types
14 }
15
16 fn get_max_from_min<'min, 'max, G>()
17     where 'max : 'min, G : 'max, &'min G : Get
18 {
19     // Previously OK, but now error because traits are invariant with
20     // respect to all inputs.
21
22     impls_get::<&'max G>(); //~ ERROR mismatched types
23 }
24
25 fn impls_get<G>() where G : Get { }
26
27 fn main() { }