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