Unhelpful error message when using bad receiver type #57994
Description
Consider the following piece of code:
use std::pin::Pin;
trait Test {
fn test(self: Pin<&mut Self>);
}
fn foo(t: impl Test) {
t.test()
}
The error here is that test
can only be called on Pin<&mut Self>
, so t.test
does not work. But the error message is less than helpful:
error[E0599]: no method named `test` found for type `impl Test` in the current scope
--> src/lib.rs:8:7
|
8 | t.test()
| ^^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
candidate #1: `Test`
It suggests I import a trait that is already in scope. This leads down the totally wrong path -- not showing the "help" and "note" at all would be better than this. Ideally it could point out the receiver type mismatch.