diff options
Diffstat (limited to 'src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs')
-rw-r--r-- | src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs b/src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs new file mode 100644 index 000000000..6c7c46b0e --- /dev/null +++ b/src/test/ui/impl-trait/associated-impl-trait-type-generic-trait.rs @@ -0,0 +1,30 @@ +#![feature(type_alias_impl_trait)] +// build-pass (FIXME(62277): could be check-pass?) + +trait Bar {} +struct Dummy<U>(U); +impl<V> Bar for Dummy<V> {} + +trait Foo<T> { + type Assoc: Bar; + fn foo(t: T) -> Self::Assoc; +} + +impl<W> Foo<W> for i32 { + type Assoc = impl Bar; + fn foo(w: W) -> Self::Assoc { + Dummy(w) + } +} + +struct NonGeneric; +impl Bar for NonGeneric {} + +impl<W> Foo<W> for u32 { + type Assoc = impl Bar; + fn foo(_: W) -> Self::Assoc { + NonGeneric + } +} + +fn main() {} |