]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/generic-associated-type-bounds.rs
Rollup merge of #102854 - semarie:openbsd-immutablestack, r=m-ou-se
[rust.git] / src / test / ui / generic-associated-types / generic-associated-type-bounds.rs
1 // run-pass
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 ()>) -> &() {
17     x.m()
18 }
19
20 fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &() {
21     x.m()
22 }
23
24 fn h(x: &()) -> &() {
25     x.m()
26 }
27
28 fn main() {
29     f(&());
30     g(&());
31     h(&());
32 }