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 transmute docs with further clarifications #82592

Merged
merged 1 commit into from
Mar 7, 2021
Merged

Improve transmute docs with further clarifications #82592

merged 1 commit into from
Mar 7, 2021

Conversation

Lonami
Copy link
Contributor

@Lonami Lonami commented Feb 27, 2021

Closes #82493.

Please let me know if any of the new wording sounds off, English is not my mother tongue.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2021
@Mark-Simulacrum
Copy link
Member

cc @RalfJung -- does this sound reasonable to you?

@@ -841,11 +841,21 @@ extern "rust-intrinsic" {
/// Both types must have the same size. Neither the original, nor the result,
/// may be an [invalid value](../../nomicon/what-unsafe-does.html).
///
/// When transmuting containers, make sure to not violate the container invariants too.
/// Some containers might rely on the size of the type, alignment, or even the `TypeId`,
/// in which case transmuting wouldn't be possible without violating the container invariants.
Copy link
Member

@RalfJung RalfJung Mar 6, 2021

Choose a reason for hiding this comment

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

Oh, you moved it all the way up here, that was a misunderstanding... I think this is less important than some of the comments that follow, so this is too prominent of a position IMO.

What I meant was to put this together with "Turning a Vec<&T> into a Vec<Option<&T>>". And I meant the entire paragraph; now the "To transmute the inner type of the contents of a container" still exists down there in the code and duplicates some of the text, which seems redundant.

@Lonami
Copy link
Contributor Author

Lonami commented Mar 6, 2021

I'm not entirely happy with the wording on 2e6d3fa, please let me know if you have more suggestions. Heh, so much back and forth, and I thought documentation changes were among the easiest possible changes.

@RalfJung
Copy link
Member

RalfJung commented Mar 6, 2021

and I thought documentation changes were among the easiest possible changes.

Good documentation for unsafe functions is a very tricky subject. Thanks for seeing this through. :)
(But also, if I am being too nitpicky, please let me know.)

@RalfJung
Copy link
Member

RalfJung commented Mar 6, 2021

I made one final tweak, I think this is ready now. :)
Can you squash these commits together into one? (If not, no big deal, we can also land as-is if needed.)

@Lonami
Copy link
Contributor Author

Lonami commented Mar 6, 2021

Should be good to go!

@RalfJung
Copy link
Member

RalfJung commented Mar 6, 2021

Awesome. :D
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 6, 2021

📌 Commit fbc1741 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Mar 6, 2021
Improve transmute docs with further clarifications

Closes rust-lang#82493.

Please let me know if any of the new wording sounds off, English is not my mother tongue.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 6, 2021
Improve transmute docs with further clarifications

Closes rust-lang#82493.

Please let me know if any of the new wording sounds off, English is not my mother tongue.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2021
Rollup of 13 pull requests

Successful merges:

 - rust-lang#77916 (Change built-in kernel targets to be os = none throughout)
 - rust-lang#82130 (Make some Option, Result methods unstably const)
 - rust-lang#82292 (Prevent specialized ZipImpl from calling `__iterator_get_unchecked` twice with the same index)
 - rust-lang#82402 (Remove RefCell around `module_trait_cache`)
 - rust-lang#82592 (Improve transmute docs with further clarifications)
 - rust-lang#82651 (Cleanup rustdoc warnings)
 - rust-lang#82720 (Fix diagnostic suggests adding type `[type error]`)
 - rust-lang#82751 (improve offset_from docs)
 - rust-lang#82793 (Move some tests to more suitable subdirs)
 - rust-lang#82803 (rustdoc: Add an unstable option to print all unversioned files)
 - rust-lang#82808 (Sync rustc_codegen_cranelift)
 - rust-lang#82822 (Fix typo)
 - rust-lang#82837 (tweak MaybeUninit docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 817e58f into rust-lang:master Mar 7, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 7, 2021
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.

transmute documentation does not explicitly mention alignment requirement
6 participants