]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/generic-associated-type-bounds.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / generic-associated-types / generic-associated-type-bounds.rs
1 // run-pass
2
3 #![feature(generic_associated_types)]
4
5 pub trait X {
6     type Y<'a> where Self: 'a;
7     fn m(&self) -> Self::Y<'_>;
8 }
9
10 impl X for () {
11     type Y<'a> = &'a ();
12
13     fn m(&self) -> Self::Y<'_> {
14         self
15     }
16 }
17
18 fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &() {
19     x.m()
20 }
21
22 fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &() {
23     x.m()
24 }
25
26 fn h(x: &()) -> &() {
27     x.m()
28 }
29
30 fn main() {
31     f(&());
32     g(&());
33     h(&());
34 }