]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obk
authorbors <bors@rust-lang.org>
Thu, 30 Jul 2020 12:52:41 +0000 (12:52 +0000)
committerbors <bors@rust-lang.org>
Thu, 30 Jul 2020 12:52:41 +0000 (12:52 +0000)
Make `mem::size_of_val` and `mem::align_of_val` unstably const

Implements #46571 but does not stabilize it. I wanted this while working on something today.

The only reason not to immediately stabilize are concerns around [custom DSTs](https://github.com/rust-lang/rust/issues/46571#issuecomment-387669352). That proposal has made zero progress in the last two years and const eval is rich enough to support pretty much any user-defined `len` function as long as nightly features are allowed (`raw_ptr_deref`).

Currently, this raises a `const_err` lint when passed an `extern type`.

r? @oli-obk

cc @rust-lang/wg-const-eval

1  2 
src/librustc_mir/interpret/intrinsics.rs