diff options
Diffstat (limited to 'src/test/ui/generic-associated-types/generic-associated-type-bounds.rs')
-rw-r--r-- | src/test/ui/generic-associated-types/generic-associated-type-bounds.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/generic-associated-type-bounds.rs b/src/test/ui/generic-associated-types/generic-associated-type-bounds.rs new file mode 100644 index 000000000..d7c4dbda2 --- /dev/null +++ b/src/test/ui/generic-associated-types/generic-associated-type-bounds.rs @@ -0,0 +1,34 @@ +// run-pass + +#![feature(generic_associated_types)] + +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(&()); +} |