-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.
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.
reneeichhorn, jgrund, arilotter, ikamensh, niedzielski and 4 more
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.