-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
mem::{size,align,min_align}_of_val should accept DSTs #19063
Labels
A-DSTs
Area: Dynamically-sized types (DSTs)
Comments
cc @japaric |
This is almost done now— |
@P1start I wonder how we should go about supporting that, as trait objects store only |
This is fixed -- because align_of_val now is minimum alignment. |
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Feb 10, 2025
…ut-struct-default-fields internal: backout `hir-*` changes from rust-lang#19001
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
mem::size_of_val
and friends only support sized types, and just defer tomem::size_of
etc.. Ideally, they would also support dynamically-sized types, in a way such thatsize_of_val(&[1, 2, 3]: &[int]) == size_of::<int>() * 3
. Because this requires an actual value, they wouldn’t be able to simply defer to callingsize_of
etc. and would instead have to become intrinsic functions. I believe that this issue makes implementing pointer types that accept dynamically-sized type parameters very difficult (if not impossible) (e.g., #18248 (although I think that also might require a way of running destructors for unsized values)).The text was updated successfully, but these errors were encountered: