Skip to content

By-value self methods on trait objects have bad error messages #9893

Closed
@alexcrichton

Description

@alexcrichton

If I have ownership of a trait object, I would expect to be able to call a by-value self method defined on the trait. For example:

trait A { fn foo(self) {} }    

fn foo(a: ~A) {                
    a.foo();                   
}    
struct B;                      
impl A for B {}                

fn main() {                    
    foo(~B as ~A);             
}

currently yields the error of:

foo.rs:4:4: 4:12 error: type `~A:Send` does not implement any method in scope named `foo`
foo.rs:4     a.foo();
             ^~~~~~~~
error: aborting due to previous error

Nominating for the backcompat-lang 1.0 milestone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions