]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs
Move some tests with compare-mode=nll output to revisions
[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 `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
19 }
20
21 fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
22     x.m()
23     //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
24 }
25
26 fn h(x: &()) -> &'static () {
27     x.m()
28     //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
29 }
30
31 fn main() {
32     f(&());
33     g(&());
34     h(&());
35 }