Unsoundness in `Pin`

The other option is to reserve the impl (basically a poor man's negative impl)

#[rustc_reservation_impl=
    "a custom implementation would be permitted since &_ is fundamental, but be very unexpected, \
    and Pin requires the lack of this impl for soundness"]
impl<T: ?Sized> DerefMut for &'_ T {
    fn deref_mut(&&T) -> Self::Target {
        panic!("not allowed")
    }
}

#[rustc_reservation_impl=
    "a custom implementation would be permitted since &_ is fundamental, but be very unexpected, \
    and Pin requires the lack of this impl for soundness"]
impl<T: ?Sized> Clone for &'_ mut T {
    fn clone(&&mut T) -> Self {
        panic!("not allowed")
    }
}
12 Likes