Pin::new_unchecked docs need to warn about Ptr: Drop too #134874
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
Location
https://doc.rust-lang.org/std/pin/struct.Pin.html#method.new_unchecked
Summary
The
pin
module-level doc saysHowever, the doc for
Pin::new_unchecked
saysIf I understand correctly (which I may well not, given the subject matter...), these two sections are talking about the same thing: there are some safe traits that you implement by writing a method that takes a bare
&mut self
, and when those traits are implemented for thePtr
type in aPin<Ptr<T>>
, unlessT: Unpin
, you really need to treat that&mut self
as if it were pinned (maybe by stuffing it inside aPin
ASAP), or you are in danger of breaking invariants that unsafe code is allowed to assume. And because this is a safety requirement, there's got to be anunsafe
somewhere stating that you believe those safe traits are implemented appropriately, and that place is, I think, the invocation ofPin::new_unchecked
for a specific choice ofPtr
type.But the doc for
Pin::new_unchecked
only mentionsDeref
andDerefMut
as part of the safety contract of invoking it. If these sections are talking about the same thing, then properly implementingDrop
is also part of the safety burden and the doc should mention it.The text was updated successfully, but these errors were encountered: