-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
docs: Changed docs for size_of
to describe size as a stride offset
#33335
Conversation
Current description of `std::mem::size_of` is ambiguous, and the `std::intrinsics::size_of` description incorrectly defines size as the number of bytes necessary to exactly overwrite a value, not including the padding between elements necessary in a vector or structure.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (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. |
If I only have one |
@durka I can't give you a definitive answer on that-- perhaps @pnkfelix can shed some light. I would speculate, however, that it would allocate exactly LLVM's getTypeAllocSize, seeing as this seems to be literally the allocation size of the type. This would guarantee alignment for future allocations of the type, although I'd imagine the actual heap-alignment is more heavily dependent upon the allocator in question. This would also fall in line with @pnkfelix's comment that the behavior of Note, too, that LLVM also provides a getTypeStoreSize specifying the number of bytes overwritten by the object in question, a more traditional/intuitive understanding of |
@alexcrichton I think the answer to my question should go into the |
Sounds like something that'd be more appropriate for |
docs: Changed docs for `size_of` to describe size as a stride offset Current documentation for `std::mem::size_of` is ambiguous, and the documentation for `std::intrinsics::size_of` incorrectly defines size. This fix re-defines size as the offset in bytes between successive instances of a type, as described in LLVM's [getTypeAllocSize](http://llvm.org/docs/doxygen/html/classllvm_1_1DataLayout.html#a1d6fcc02e91ba24510aba42660c90e29). Fixes: rust-lang#33266
docs: Changed docs for `size_of` to describe size as a stride offset Current documentation for `std::mem::size_of` is ambiguous, and the documentation for `std::intrinsics::size_of` incorrectly defines size. This fix re-defines size as the offset in bytes between successive instances of a type, as described in LLVM's [getTypeAllocSize](http://llvm.org/docs/doxygen/html/classllvm_1_1DataLayout.html#a1d6fcc02e91ba24510aba42660c90e29). Fixes: rust-lang#33266
Current documentation for
std::mem::size_of
is ambiguous, and the documentation forstd::intrinsics::size_of
incorrectly defines size.This fix re-defines size as the offset in bytes between successive instances of a type, as described in LLVM's getTypeAllocSize.
Fixes: #33266