Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology #71625

Merged
merged 1 commit into from
May 16, 2020

Conversation

Diggsey
Copy link
Contributor

@Diggsey Diggsey commented Apr 27, 2020

@rust-highfive
Copy link
Collaborator

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 27, 2020
@Diggsey Diggsey force-pushed the improve-manually-drop-docs branch 2 times, most recently from 72bdab5 to 34c5e0c Compare April 28, 2020 21:28
src/libcore/ptr/mod.rs Outdated Show resolved Hide resolved
@@ -112,11 +112,17 @@ mod mut_ptr;
/// as the compiler doesn't need to prove that it's sound to elide the
/// copy.
///
/// * It can be used to drop [pinned] data (pinned data must not be moved
/// before it is dropped).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// before it is dropped).
/// before it is dropped), except if `T` is `repr(packed).

I feel currently this reads a bit like a contradiction, where it says "can be used to drop pinned data (because in-place)" but later says "but fields of packed structs are not dropped in-place".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUI, packed structs with destructors cannot be pinned to begin with, and packed structs without destructors are presumably safe to drop using this function anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They cannot be pinned precisely because of what this comment says. If someone tries anyway, this is the place where they are violating the rules. So this is the place where that should be mentioned.

The compiler won't stop you when you try to pin something packed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I put the caveat before the part in brackets because I felt it was awkward to read otherwise.

@cramertj
Copy link
Member

cramertj commented May 8, 2020

r? @RalfJung

@rust-highfive rust-highfive assigned RalfJung and unassigned cramertj May 8, 2020
@RalfJung RalfJung added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2020
@Diggsey Diggsey force-pushed the improve-manually-drop-docs branch from 241ab21 to d8a3e59 Compare May 15, 2020 18:48
@Diggsey Diggsey force-pushed the improve-manually-drop-docs branch from d8a3e59 to 7433c4d Compare May 15, 2020 18:53
@RalfJung
Copy link
Member

This looks great, thanks a lot. :)
@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 16, 2020

📌 Commit 7433c4d has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 16, 2020
@RalfJung RalfJung changed the title Improve the documentation for ManuallyDrop to resolve conflicting usa… Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology May 16, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#71625 (Improve the documentation for ManuallyDrop to resolve conflicting usage of terminology)
 - rust-lang#71919 (Update transitive dependency to work towards removing syn <1.0 dep)
 - rust-lang#72166 (Simpler slice `Iterator` methods)
 - rust-lang#72216 (Remove `lang_items\(\).*\.unwrap\(\)`)
 - rust-lang#72230 (Updated documentation of Prefix::VerbatimDisk)
 - rust-lang#72234 (Implement Default for proc_macro::TokenStream)
 - rust-lang#72258 (Fix typo Arbintrary to Arbitrary)

Failed merges:

r? @ghost
@bors bors merged commit 9c32e7a into rust-lang:master May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants