mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-04 17:22:19 +00:00
Stabilize `mem::conjure_zst` Tracking issue: https://github.com/rust-lang/rust/issues/95383 --- Stabilized API: ```rust pub const unsafe fn conjure_zst<T>() -> T; ``` The notable thing about this implementation is that if this function is called at run time (as opposed to in consteval), then the function will panic at run time (as opposed to at compile time) if `T` is not a ZST. If the function panics in consteval, the panic message is a fixed literal string. If the function panics at run time, the panic message includes the `type_name` of `T`. Note that [`type_name`](https://doc.rust-lang.org/nightly/std/any/fn.type_name.html) is currently [unstable in const](https://github.com/rust-lang/rust/issues/63084). --- Implementation history: * https://github.com/rust-lang/rust/pull/95385 (attempted to add the API without an ACP, and then the PR was closed) * https://github.com/rust-lang/libs-team/issues/292 (The ACP. It has a lot of additional context and discussion, including the explanation of why this is needed) * https://github.com/rust-lang/rust/pull/146479 (the actual implementation) * https://github.com/rust-lang/rust/pull/153073 (changes the panic message) * https://github.com/rust-lang/rust/pull/155840 (internal implementation change)