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

Clarify the docs for align_of and its variants #42252

Merged
merged 2 commits into from May 31, 2017
Merged

Clarify the docs for align_of and its variants #42252

merged 2 commits into from May 31, 2017

Conversation

ghost
Copy link

@ghost ghost commented May 26, 2017

It's okay to have unaligned raw pointers and then use ptr::write_unaligned and ptr::read_unaligned.
However, using unaligned &T and &mut T would be undefined behavior.

The current documentation seems to indicate that everything has to be aligned, but in reality only references do. This PR changes the text of docs accordingly.

r? @sfackler

@ghost ghost changed the title Clarify the docs for align_of and it's variants Clarify the docs for align_of and its variants May 26, 2017
@shepmaster
Copy link
Member

Thanks for the PR! We'll get @sfackler (or someone almost as awesome) on the case!

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 27, 2017
@sfackler
Copy link
Member

@rust-lang/lang is this the right phrasing to use here? I'm not totally sure on the exact semantics we want to require WRT alignment.

@nikomatsakis
Copy link
Contributor

This phrasing seems correct. Not sure if it is perfect, but it's not wrong.

@nikomatsakis
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 31, 2017

📌 Commit c25e271 has been approved by nikomatsakis

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 31, 2017
…komatsakis

Clarify the docs for align_of and its variants

It's okay to have unaligned raw pointers and then use `ptr::write_unaligned` and `ptr::read_unaligned`.
However, using unaligned `&T` and `&mut T` would be undefined behavior.

The current documentation seems to indicate that everything has to be aligned, but in reality only references do. This PR changes the text of docs accordingly.

r? @sfackler
bors added a commit that referenced this pull request May 31, 2017
Rollup of 7 pull requests

- Successful merges: #42126, #42196, #42252, #42277, #42315, #42329, #42330
- Failed merges:
@bors bors merged commit c25e271 into rust-lang:master May 31, 2017
@ghost ghost deleted the clarify-alignof-docs branch June 1, 2017 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants