Closed
Description
The following code produces a very confusing error message.
struct Foo;
impl Foo {
fn consume(self: Box<Self>) {}
}
fn bar() {
let x = Foo;
x.consume();
}
error[E0599]: no method named `consume` found for type `Foo` in the current scope
--> src/lib.rs:9:7
|
1 | struct Foo;
| ----------- method `consume` not found for this
...
9 | x.consume();
| ^^^^^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `consume`, perhaps you need to implement it:
candidate #1: `std::io::BufRead`
error: aborting due to previous error
I would expect it to mention that consume
expects Box<Foo>
but x
is only of type Foo
.