-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Pin::new_unchecked docs need to warn about Ptr: Drop too #134874
Copy link
Copy link
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-pinArea: PinArea: PinT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-pinArea: PinArea: PinT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Location
https://doc.rust-lang.org/std/pin/struct.Pin.html#method.new_unchecked
Summary
The
pinmodule-level doc saysHowever, the doc for
Pin::new_uncheckedsaysIf 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 thePtrtype in aPin<Ptr<T>>, unlessT: Unpin, you really need to treat that&mut selfas if it were pinned (maybe by stuffing it inside aPinASAP), 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 anunsafesomewhere stating that you believe those safe traits are implemented appropriately, and that place is, I think, the invocation ofPin::new_uncheckedfor a specific choice ofPtrtype.But the doc for
Pin::new_uncheckedonly mentionsDerefandDerefMutas part of the safety contract of invoking it. If these sections are talking about the same thing, then properly implementingDropis also part of the safety burden and the doc should mention it.