]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-covariant-self-trait-match.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / variance / variance-covariant-self-trait-match.rs
1 #![allow(dead_code)]
2
3 // Test that even when `Self` is only used in covariant position, it
4 // is treated as invariant.
5
6 // revisions: base nll
7 // ignore-compare-mode-nll
8 //[nll] compile-flags: -Z borrowck=mir
9
10 trait Get {
11     fn get() -> Self;
12 }
13
14 fn get_min_from_max<'min, 'max, G>()
15     where 'max : 'min, G : 'max, &'max G : Get
16 {
17     // Previously OK, now an error as traits are invariant.
18     impls_get::<&'min G>();
19     //[base]~^ ERROR mismatched types
20     //[nll]~^^ ERROR lifetime may not live long enough
21 }
22
23 fn get_max_from_min<'min, 'max, G>()
24     where 'max : 'min, G : 'max, &'min G : Get
25 {
26     impls_get::<&'max G>();
27     //[base]~^ ERROR mismatched types
28     //[nll]~^^ ERROR lifetime may not live long enough
29 }
30
31 fn impls_get<G>() where G : Get { }
32
33 fn main() { }