Closed
Description
Code
I tried this code:
const _: () = {
if false {
panic!("hello world: {}", "foo"); // works only in stable
}
};
I expected to see this happen: Compiles without error.
Instead, this happened:
Compiling playground v0.0.1 (/playground)
error[E0015]: cannot call non-const formatting macro in constants
--> src/lib.rs:3:9
|
3 | panic!("hello world: {}", "foo"); // works only in stable
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
Version it worked on
It most recently worked on: 1.87 (beta).
Version with regression
rustc --version --verbose
:
~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
rustc 1.88.0-nightly (3350c1eb3 2025-05-01)
binary: rustc
commit-hash: 3350c1eb3fd8fe1bee1ed4c76944d707bd256876
commit-date: 2025-05-01
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2