]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs
Rollup merge of #101741 - andrewpollack:add-needs-unwind-ui-tests, r=tmandry
[rust.git] / src / test / ui / generic-associated-types / projection-type-lifetime-mismatch.rs
1 pub trait X {
2     type Y<'a> where Self: 'a;
3     fn m(&self) -> Self::Y<'_>;
4 }
5
6 impl X for () {
7     type Y<'a> = &'a ();
8
9     fn m(&self) -> Self::Y<'_> {
10         self
11     }
12 }
13
14 fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
15     x.m()
16     //~^ ERROR lifetime may not live long enough
17 }
18
19 fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
20     x.m()
21     //~^ ERROR lifetime may not live long enough
22 }
23
24 fn h(x: &()) -> &'static () {
25     x.m()
26     //~^ ERROR lifetime may not live long enough
27 }
28
29 fn main() {
30     f(&());
31     g(&());
32     h(&());
33 }