]> git.proxmox.com Git - rustc.git/blob - src/test/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / generic-associated-types / issue-78113-lifetime-mismatch-dyn-trait-box.rs
1 // Test for diagnostics when we have mismatched lifetime due to implict 'static lifetime in GATs
2
3 // check-fail
4
5 #![feature(generic_associated_types)]
6
7 pub trait A {}
8 impl A for &dyn A {}
9 impl A for Box<dyn A> {}
10
11 pub trait B {
12 type T<'a>: A;
13 }
14
15 impl B for () {
16 // `'a` doesn't match implicit `'static`: suggest `'_`
17 type T<'a> = Box<dyn A + 'a>; //~ incompatible lifetime on type
18 }
19
20 trait C {}
21 impl C for Box<dyn A + 'static> {}
22 pub trait D {
23 type T<'a>: C;
24 }
25 impl D for () {
26 // `'a` doesn't match explicit `'static`: we *should* suggest removing `'static`
27 type T<'a> = Box<dyn A + 'a>; //~ incompatible lifetime on type
28 }
29
30 trait E {}
31 impl E for (Box<dyn A>, Box<dyn A>) {}
32 pub trait F {
33 type T<'a>: E;
34 }
35 impl F for () {
36 // `'a` doesn't match explicit `'static`: suggest `'_`
37 type T<'a> = (Box<dyn A + 'a>, Box<dyn A + 'a>); //~ incompatible lifetime on type
38 }
39
40 fn main() {}