`_` placeholders in type aliases with defaulted generics

Hello. Having a generic struct with default parameters, I want to define type aliases for it. Unfortunately, it doesn't compile:

struct Const;

struct Unit<L = Const, M = Const>(PhantomData<(L, M)>);

type Length<L> = Unit<L>; // OK
type Mass<M> = Unit<Const, M> // OK
type Mass2<M> = Unit<_, M> // Error E0121

I've briefly searched for RFCs/issues and found RFC 0213. Unfortunately it seems abandoned since 2020. Any chance to revive it? What are the blockers?

The main problem is that _ is "infer this," not "use the default".

In the specific case of type aliases, the only possible choice would seem to be the default... but that's not the case, as e.g. type alias impl trait is inferred (to the defining use(s)), not defaulted.

2 Likes