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

Explicitly mention in the docs that grow, grow_zeroed, and shrink have to handle changes in alignment #97

Closed
autumnontape opened this issue Mar 30, 2022 · 4 comments

Comments

@autumnontape
Copy link

The docs currently imply that the alignment of new_layout may be different from that of old_layout by not stating otherwise. Reallocations with altered alignments are extremely uncommon; I had to track down #5 in this repository to convince myself this wasn't a mistake. This could be a pitfall for implementors of Allocator if it's not made more explicit.

@Amanieu
Copy link
Member

Amanieu commented Mar 31, 2022

Sounds good, would you be willing to make a PR to rust-lang/rust to update the documentation?

@autumnontape
Copy link
Author

Sure! I can probably do that a few hours from now.

@autumnontape
Copy link
Author

I've opened rust-lang/rust#95546.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 1, 2022
…n-docs, r=Amanieu

add notes about alignment-altering reallocations to Allocator docs

As I said in rust-lang/wg-allocators#97, the fact that calls to `grow`, `grow_zeroed`, and `shrink` may request altered alignments is surprising and may be a pitfall for implementors of `Allocator` if it's left implicit. This pull request adds a note to the "Safety" section of each function's docs making it explicit.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 1, 2022
…n-docs, r=Amanieu

add notes about alignment-altering reallocations to Allocator docs

As I said in rust-lang/wg-allocators#97, the fact that calls to `grow`, `grow_zeroed`, and `shrink` may request altered alignments is surprising and may be a pitfall for implementors of `Allocator` if it's left implicit. This pull request adds a note to the "Safety" section of each function's docs making it explicit.
@autumnontape
Copy link
Author

rust-lang/rust#95546 was merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants