Skip to content

Commit f65250b

Browse files
committed
Document workaround in docs
1 parent cd44cd0 commit f65250b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

library/core/src/pin.rs

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

1758+
/// The `Target` type is restricted to `Unpin` types as it's not safe to obtain a mutable reference
1759+
/// to a pinned value.
1760+
///
1761+
/// For soundness reasons, implementations of `DerefMut` for `Pin<T>` are rejected even when `T` is
1762+
/// a local type not covered by this impl block. (Since `Pin` is [fundamental], such implementations
1763+
/// would normally be possible.)
1764+
///
1765+
/// [fundamental]: ../../reference/items/implementations.html#r-items.impl.trait.fundamental
17581766
#[stable(feature = "pin", since = "1.33.0")]
17591767
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
17601768
#[cfg(doc)]
17611769
impl<Ptr> const DerefMut for Pin<Ptr>
17621770
where
17631771
Ptr: [const] DerefMut,
1764-
Ptr::Target: Unpin,
1772+
<Ptr as Deref>::Target: Unpin,
17651773
{
17661774
fn deref_mut(&mut self) -> &mut Ptr::Target {
17671775
Pin::get_mut(Pin::as_mut(self))

0 commit comments

Comments
 (0)