Currently one cannot call unreachable_unchecked in constant functions, so one cannot add hints of the form:
const fn foo(x: i32) -> i32 {
if x < 0 { unreachable_unchecked() } else { x * 2 }
}
These types of hints can heavily influence code generation, which can substantially change the performance of const fn when they are invoked at run-time.
It would be a shame to have to write and call foo_compile_time and foo_run_time because the code generated for foo_compile_time is sub-par.
This issue has been assigned to @canova via this comment.
Currently one cannot call
unreachable_uncheckedin 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
const fnwhen they are invoked at run-time.It would be a shame to have to write and call
foo_compile_timeandfoo_run_timebecause the code generated forfoo_compile_timeis sub-par.This issue has been assigned to @canova via this comment.