-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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).
taiki-e, estebank, overdrivenpotato, chmln and hcpl
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.