`Pin::new_unchecked` and `&'a mut T`

The docs claim:

calling Pin::new_unchecked on an &'a mut T is unsafe because while you are able to pin it for the given lifetime 'a , you have no control over whether it is kept pinned once 'a ends

However, &'a mut T is Unpin, and so Pin::new on a mutable reference works fine. What am I missing?

Pin::new requires that the target of the reference (T) is Unpin. You can't pass a mutable reference to a type that isn't Unpin to Pin::new.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.