Change:
Currently one cannot call in constant functions, so one cannot add hints of the form: These types of hints can heavily influence code generation, which can substantially change the performance of when they are invoked at run-time. It would be a shame to have to write and call and because the code generated for is sub-par. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
One cannot do any sort of conditional control flow, so would currently be less than useless. Any test you can write would be undefined behaviour
the RFC for / in const was merged and is pending an implementation right? When that's implemented, will still be useless?
No it makes sense after we have conditional control flow.
As I understand / in const functions is now implemented. Can be made into a now?
yes. Basically you just need to add the attribute to the intrinsic and wrapper function. This is documented at https://rustc-dev- Let me know if anything is unclear (in which case we should update the guide)
Hi, It looks like previous PR is not being worked on currently. I'm working on this and will create a PR soon. claim
As mentioned in , this issue should be reopened (to track stablization)
cc ^
After a short discussion on Zulip, it was decided that it's best to wait for to stabilize to avoid a potential footgun wherein users use this instead of , leading to UB at runtime. I'm subscribed to the issue and intend to file a PR to stabilize this once the aforementioned happens.

Discussion:
/// ``` #[inline] #[stable(feature = "unreachable", since = "1.27.0")] <del> #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] </del> <ins> #[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] </ins> pub const unsafe fn unreachable_unchecked() -> ! { // SAFETY: the safety contract for `intrinsics::unreachable` must // be upheld by the caller.

/// reach code marked with this function. /// /// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`]. <del> #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] </del> <ins> #[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] </ins> pub fn unreachable() -> !; /// Informs the optimizer that a condition is always true.

#![feature(const_trait_impl)] #![feature(const_type_id)] #![feature(const_type_name)] <del> #![feature(const_unreachable_unchecked)] </del> #![feature(const_default_impls)] #![feature(duration_consts_2)] #![feature(ptr_metadata)]

// run-pass <del> #![feature(const_unreachable_unchecked)] </del> const unsafe fn foo(x: bool) -> bool { match x { true => true,

const BAR: bool = unsafe { foo(true) }; fn main() { <del> assert_eq!(BAR, true); </del> <ins> assert_eq!(BAR, true); </ins> }

// error-pattern: evaluation of constant value failed <del> #![feature(const_unreachable_unchecked)] </del> const unsafe fn foo(x: bool) -> bool { match x {

const BAR: bool = unsafe { foo(false) }; fn main() { <del> assert_eq!(BAR, true); </del> <ins> assert_eq!(BAR, true); </ins> }

|              entering unreachable code |              inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL | <del> ::: $DIR/const_unsafe_unreachable_ub.rs:7:18 </del> <ins> ::: $DIR/const_unsafe_unreachable_ub.rs:6:18 </ins> | LL |         false => std::hint::unreachable_unchecked(), <del> |                  ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18 </del> <ins> |                  ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:6:18 </ins> ... LL | const BAR: bool = unsafe { foo(false) }; <del> |                            ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28 </del> <ins> |                            ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:10:28 </ins> error: aborting due to previous error