Trait bound on associated type causes confusing compilation error #58231
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-diagnostics
Area: Messages for errors, warnings, and lints
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.
This code fails to compile:
The error is confusing because
Self::Item
isi32
. Furthermore, changing the bound onP
to the suggested bound (setting aside the fact that this is a trait impl so imposing additional bounds isn't necessarily appropriate) yields an even more confusing error:Adding an additional type parameter to the fn and using that as the bound on
P::Appended
appears to work fine, and i think it is semantically equivalent (although applying the bound directly to the associated type is cleaner IMO):Should the original code compile? If not, the error message (and suggested fix) is monumentally unhelpful. Otherwise, if it should compile, this looks like a compiler bug.
The text was updated successfully, but these errors were encountered: