]> git.proxmox.com Git - rustc.git/blob - src/test/ui/generic-associated-types/generic-associated-type-bounds.rs
New upstream version 1.58.1+dfsg1
[rustc.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 }