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

mem::{size,align,min_align}_of_val should accept DSTs #19063

Closed
ftxqxd opened this issue Nov 18, 2014 · 4 comments
Closed

mem::{size,align,min_align}_of_val should accept DSTs #19063

ftxqxd opened this issue Nov 18, 2014 · 4 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs)

Comments

@ftxqxd
Copy link
Contributor

ftxqxd commented Nov 18, 2014

Currently, mem::size_of_val and friends only support sized types, and just defer to mem::size_of etc.. Ideally, they would also support dynamically-sized types, in a way such that size_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 calling size_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)).

@aturon
Copy link
Member

aturon commented Nov 24, 2014

cc @japaric

@steveklabnik steveklabnik added the A-DSTs Area: Dynamically-sized types (DSTs) label Jan 29, 2015
@ftxqxd
Copy link
Contributor Author

ftxqxd commented May 15, 2015

This is almost done now—size_of_val and min_align_of_val now accept DSTs, but align_of_val still doesn’t.

@eddyb
Copy link
Member

eddyb commented May 25, 2015

@P1start I wonder how we should go about supporting that, as trait objects store only min_align_of.

@bluss
Copy link
Member

bluss commented Nov 23, 2015

This is fixed -- because align_of_val now is minimum alignment.

@bluss bluss closed this as completed Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants