-
Notifications
You must be signed in to change notification settings - Fork 13.3k
mem::size_of() is not a const function #34078
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
|
Err, wait, nevermind, wasn't testing correctly. Anyway, seems reasonable (although it would probably be tricky to support in certain contexts, like array bounds). |
It's not arbitrary, just very hard to support in the current compilation, which is at odds with CTFE. |
This pretty annoying, you can't use it in side of trait const expressions now.
Clearly this doesn't work, but it seams like it should. |
I think the active thread on this is rust-lang/rfcs#1144 but the associated constant one rust-lang/rfcs#1168 looked cool too. |
@eddyb tells me on IRC that implementation difficulties are now longer relevant now that type checking happens on demand. |
There's a PR open for this now: #42859 |
Implement const fn {size,align}_of. Fixes #34078. r? @nikomatsakis
mem::size_of()
is not a const function, even though it is always a compile-time constant. This is seemingly arbitrary and is annoying in practice.The text was updated successfully, but these errors were encountered: