Skip to content

The 2021 panic macro no longer works in const functions #87466

Closed
@AaronKutch

Description

@AaronKutch

I encountered one issue when trying to migrate my crates to edition 2021. This no longer compiles:

#![feature(const_panic)]

pub const fn f() {
    panic!("important info");
}

I understand that this requires a nightly feature to observe, but const_panic was really close to stabilizing and I use this in a lot of places. Is it possible to adjust the underlying format_args to be const with a static string input, or is there something else I should use? I don't want to go back to using the weird out-of-bounds indexing hack when trying to convey messages from a const function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-edition-2021Area: The 2021 editionA-error-handlingArea: Error handlingrequires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions