1 A type alias impl trait can only have its hidden type assigned
2 when used fully generically (and within their defining scope).
6 #![feature(type_alias_impl_trait)]
8 type Foo<T> = impl std::fmt::Debug;
10 fn foo() -> Foo<u32> {
15 is not accepted. If it were accepted, one could create unsound situations like
18 #![feature(type_alias_impl_trait)]
20 type Foo<T> = impl Default;
22 fn foo() -> Foo<u32> {
27 let x = Foo::<&'static mut String>::default();
32 Instead you need to make the function generic:
35 #![feature(type_alias_impl_trait)]
37 type Foo<T> = impl std::fmt::Debug;
39 fn foo<U>() -> Foo<U> {
44 This means that no matter the generic parameter to `foo`,
45 the hidden type will always be `u32`.
46 If you want to link the generic parameter to the hidden type,
51 #![feature(type_alias_impl_trait)]
55 type Foo<T: Debug> = impl Debug;
57 fn foo<U: Debug>() -> Foo<U> {