Skip to content

Commit

Permalink
Rollup merge of rust-lang#116007 - m-ou-se:const-panic-fmt-panic-disp…
Browse files Browse the repository at this point in the history
…lay, r=oli-obk

Call panic_display directly in const_panic_fmt.

`panic_str` just directly calls `panic_display`. The only reason `panic_str` exists, is for a lint to detect an expansion of `panic_2015!(expr)` (which expands to `panic_str`).

It is `panic_display` that is hooked by const-eval, which is the reason we call it here.

Part of rust-lang#116005

r? `@oli-obk`
  • Loading branch information
GuillaumeGomez authored Sep 21, 2023
2 parents f7c7254 + 667bba4 commit f54b64f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ fn panic_in_cleanup() -> ! {
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
if let Some(msg) = fmt.as_str() {
panic_str(msg);
// The panic_display function is hooked by const eval.
panic_display(&msg);
} else {
// SAFETY: This is only evaluated at compile time, which reliably
// handles this UB (in case this branch turns out to be reachable
Expand Down

0 comments on commit f54b64f

Please sign in to comment.