You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structFoo<T>{a:T,}structBar<'a,T>{foo:&'aFoo<T>,}impl<T>Foo<T>{fnbar<'a>(&'aself) -> Bar<'a,T>{fail!()}}impl<'a,T>Deref<T>forBar<'a,T>{fnderef<'a>(&'aself) -> &'aT{fail!()}}impl<'a,T>DerefMut<T>forBar<'a,T>{fnderef_mut<'a>(&'amutself) -> &'amutT{fail!()}}fnmain(){let a = Foo{a:Foo{a:2}};let b = a.bar();let c = b.bar();}
$ rustc foo.rs
foo.rs:23:13: 23:14 error: cannot borrow immutable local variable `b` as mutable
foo.rs:23 let c = b.bar();
^
error: aborting due to previous error
This should not require b to be mutable. If I replace b.bar() with b.deref().bar() it will compile ok.
This should not require
b
to be mutable. If I replaceb.bar()
withb.deref().bar()
it will compile ok.cc @eddyb
The text was updated successfully, but these errors were encountered: