- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-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
struct A;
impl A {
    fn foo(self: Box<Self>) {}
}
fn main() {
    A.foo()
}gives
error[E0599]: no method named `foo` found for type `A` in the current scope
 --> src/main.rs:8:7
  |
1 | struct A;
  | --------- method `foo` not found for this
...
8 |     A.foo()
  |       ^^^
When having a trait in scope, it looks like this:
trait B { fn foo(self: Box<Self>); }
struct A;
impl B for A {
    fn foo(self: Box<Self>) {}
}
fn main() {
    A.foo()
}Standard Error
   Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `foo` found for type `A` in the current scope
 --> src/main.rs:9:7
  |
2 | struct A;
  | --------- method `foo` not found for this
...
9 |     A.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: `B`
Both are not ideal. Improvements are welcomed :)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-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.