Closed
Description
Test case:
fn main() {}
struct A;
impl A {
fn b(&mut self) {
self.a()
}
}
trait Foo {}
trait Bar {
fn a(&self);
}
impl Foo for A {}
impl<T> Bar for T where T: Foo {
fn a(&self) {}
}
rustc output:
a.rs:7:9: 7:17 error: the trait `Foo` is not implemented for the type `&mut A`
a.rs:7 self.a()
^~~~~~~~
error: aborting due to previous error
Expected behavior: &mut self
is automatically converted to &self
in the self.a()
call.
The bug disappears if fn b
is changed to take &self
, if fn a
is changed to take &mut self
, or if the call is changed to (&*self).a()
.
CC @aturon