Misleading error message involving blanket implementations and associated types #55591
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.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Under some circumstances involving blanket implementations and associated types, the compiler gives a misleading error message describing the wrong trait bound.
I tried this code:
(Playground)
I expected to see an error message like this (the correct bound is
IntoProducer
):Instead, the compiler gave this error message (the bound is
Producer
):This occurs on stable (1.30.0), beta (1.31.0-beta.3), and nightly (1.31.0-nightly) on the Rust Playground.
What appears to be happening is that the compiler sees the
impl<P: Producer> IntoProducer for P
implementation and assumes that this implementation that will always be used, even though it has aP: Producer
constraint and other implementations ofIntoProducer
exist.The text was updated successfully, but these errors were encountered: