diff options
Diffstat (limited to 'tests/ui/generic-associated-types/generic-associated-type-bounds.rs')
-rw-r--r-- | tests/ui/generic-associated-types/generic-associated-type-bounds.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/generic-associated-types/generic-associated-type-bounds.rs b/tests/ui/generic-associated-types/generic-associated-type-bounds.rs new file mode 100644 index 000000000..fdc5a7267 --- /dev/null +++ b/tests/ui/generic-associated-types/generic-associated-type-bounds.rs @@ -0,0 +1,32 @@ +// run-pass + +pub trait X { + type Y<'a> where Self: 'a; + fn m(&self) -> Self::Y<'_>; +} + +impl X for () { + type Y<'a> = &'a (); + + fn m(&self) -> Self::Y<'_> { + self + } +} + +fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &() { + x.m() +} + +fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &() { + x.m() +} + +fn h(x: &()) -> &() { + x.m() +} + +fn main() { + f(&()); + g(&()); + h(&()); +} |