Closed
Description
use std::pin::Pin;
trait Foo {
fn foo(self: Pin<&Self>) {}
}
struct Bar;
impl Foo for Bar {
}
fn main() {
Bar.foo();
}
(playground) gives an error:
error[E0599]: no method named `foo` found for type `Bar` in the current scope
--> src/main.rs:12:9
|
7 | struct Bar;
| ----------- method `foo` not found for this
...
12 | Bar.foo();
| ^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `Foo`
The error isn't that the trait is unimplemented for Bar
, it's that the method requires self: Pin<&Self>
and we're trying to pass just Self
. The error message should mention the mismatched self-type (and for the builtin types that are supported by arbitrary self types it might even be able to generate proposed fixes).