Skip to content

Commit 1bda434

Browse files
committed
Document workaround in docs
1 parent 7bd94f7 commit 1bda434

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/core/src/pin.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,13 +1755,18 @@ where
17551755
}
17561756
}
17571757

1758+
/// Restricted to `Unpin` types, as it's not safe to obtain a mutable reference to a pinned value.
1759+
///
1760+
/// Note that because `Pin` is fundamental, it would normally be possible for crates to implement
1761+
/// `DerefMut` for `Pin<T>` when `T` is a local type and not covered by this impl block. However,
1762+
/// this impl block is written in a special way to prevent that for soundness reasons.
17581763
#[stable(feature = "pin", since = "1.33.0")]
17591764
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
17601765
#[cfg(doc)]
17611766
impl<Ptr> const DerefMut for Pin<Ptr>
17621767
where
17631768
Ptr: [const] DerefMut,
1764-
Ptr::Target: Unpin,
1769+
<Ptr as Deref>::Target: Unpin,
17651770
{
17661771
fn deref_mut(&mut self) -> &mut Ptr::Target {
17671772
Pin::get_mut(Pin::as_mut(self))

0 commit comments

Comments
 (0)