"Cycle computing supertraits" error could be more helpful #62581
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-traits
Area: Trait system
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider the following code:
Trying to compile it, we get the following error:
To most programmers, this just looks like Rust won't let you have a trait bound which depends on an associated type in the trait being defined. That's what I thought for a long time. But that's not actually true - what's actually going on is that in order to figure out which
F
is being referred to inSelf::F
, the supertraits need to be computed. If we help the compiler out by disambiguating whichF
we mean, the error goes away:I suggest that we improve the error message in this case to suggest disambiguating any associated types in trait bounds in order to steer users towards this solution.
The text was updated successfully, but these errors were encountered: