Skip to content

Tracking Issue for const unreachable_unchecked #53188

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation (MIR interpretation)A-const-fnArea: const fn foo(..) {..}. Pure functions which can be applied at compile time.C-tracking-issueCategory: A tracking issue for an RFC or an unstable feature.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions