]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs
Rollup merge of #82308 - estebank:issue-82290, r=lcnr
[rust.git] / src / test / ui / generic-associated-types / projection-type-lifetime-mismatch.rs
1 #![allow(incomplete_features)]
2 #![feature(generic_associated_types)]
3
4 pub trait X {
5     type Y<'a>;
6     fn m(&self) -> Self::Y<'_>;
7 }
8
9 impl X for () {
10     type Y<'a> = &'a ();
11
12     fn m(&self) -> Self::Y<'_> {
13         self
14     }
15 }
16
17 fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
18     x.m()
19     //~^ ERROR explicit lifetime required
20 }
21
22 fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
23     x.m()
24     //~^ ERROR explicit lifetime required
25 }
26
27 fn h(x: &()) -> &'static () {
28     x.m()
29     //~^ ERROR explicit lifetime required
30 }
31
32 fn main() {
33     f(&());
34     g(&());
35     h(&());
36 }