# Feature request: with \`panic\_immediate\_abort\`, core::panic! should call core::panicking::panic instead of core::panicking::panic\_fmt

**URL:** <https://internals.rust-lang.org/t/feature-request-with-panic-immediate-abort-core-panic-should-call-core-panic-instead-of-core-panic-fmt/14937>\
**Category:** compiler\
**Created:** [June 29, 2021, 4:08am UTC](https://internals.rust-lang.org/t/feature-request-with-panic-immediate-abort-core-panic-should-call-core-panic-instead-of-core-panic-fmt/14937 "2021-06-29T04:08:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElectronicRU](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/electronicru/32/8305_2.png) [@ElectronicRU](https://internals.rust-lang.org/u/ElectronicRU)\
**Post date:** [June 29, 2021, 4:08am UTC](https://internals.rust-lang.org/t/feature-request-with-panic-immediate-abort-core-panic-should-call-core-panic-instead-of-core-panic-fmt/14937/1 "2021-06-29T04:08:59Z")

</div>

Hello, I am a user of rust-gpu project. A common hurdle with using crates with rust-gpu's backend is that the backend doesn't allow complex transmutes (because SPIR-V is a rather strongly typed language), and therefore, core::fmt ends up not working, because it does a bunch of transmuting slices and `Any` types. Therefore, any crate that uses panic! with formatting ends up not working.

Recently, I've found this PR: [https://github.com/rust-lang/rust/issues/54981](https://github.com/rust-lang/rust/issues/54981). It almost works to disable panic formatting, however, it relies on LTO to remove dead code and therefore doesn't help with code emission failures.

I see a potential solution along the lines of this: specialize core::panic::panic\_\*! macros, so that, if `panic_immediate_abort` feature is enabled, call to `panic fmt(format_args!(...))` is replaced with `let _ = format_args!(...); core::panicking::panic()`. The runtime behaviour is almost identical; `let _` expression will force format\_args! to still expand and typecheck, but will be discarded during dead code elimination. (At least that's my understanding). This will allow to compile a lot of no\_std crates which only use formatting in panics.

What do you think about this?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [September 27, 2021, 4:09am UTC](https://internals.rust-lang.org/t/feature-request-with-panic-immediate-abort-core-panic-should-call-core-panic-instead-of-core-panic-fmt/14937/2 "2021-09-27T04:09:21Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
