Redundant specification of associated types with bound by inheriting trait #57218
Labels
A-trait-system
Area: Trait system
A-type-system
Area: Type system
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
Given traits:
the compiler does enforce that types implementing
C
have the required type forX
, yet claims the associated type must still be specified when used (e.g. in&C
).https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=50ed977d59b2b0ab67effef5c84d810a
I would expect that it would be unnecessary (or even illegal) to specify the type of
X
twice hence consider this a bug. This limits API design: a trait likeC
cannot retroactively have a base trait with associated type likeA
added, and in any case requiring all users to writeC<X = u32>
or equivalent is undesirable.Possibly such a change warrants an RFC, though since the extra type specification is redundant, not requiring it is not a breaking change. Making this change would however mean that an API cannot relax a constraint like
X = u32
without the change being breaking (if a library usestrait C: A<X = u32>
in its API but envisages switching totrait C: A
in the future — seems unlikely).The text was updated successfully, but these errors were encountered: