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. 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?