Closed
Description
Testcase:
use std::ops::*;
struct S<'a, T:FnMut() + 'static + ?Sized>(&'a mut T);
impl<'a, T:?Sized + FnMut() + 'static> DerefMut for S<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}
impl<'a, T:?Sized + FnMut() + 'static> Deref for S<'a, T> {
type Target = FnMut() + 'a;
fn deref(&self) -> &Self::Target { &self.0 }
}
fn main() {
let mut f = ||{};
let mut s = S(&mut f);
s();
}
Yields:
<anon>:13:5: 13:6 error: cannot borrow immutable borrowed content as mutable
<anon>:13 s();
^
Auto-deref should be picking DerefMut here, not Deref.