For a no_std
application there are a few language items defined in lang_items.rs
, one of them being the panic_fmt
language item (to specify the behavior of panic!
in this no_std
context) defined like:
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! { loop{} }
When compiling, I receive this error:
error[E0522]: definition of an unknown language item: `panic_fmt`
--> src/lang_items.rs:3:1
|
3 | #[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! { loop{} }
| ^^^^^^^^^^^^^^^^^^^^^ definition of unknown language item `panic_fmt`
error: `#[panic_implementation]` function required, but not found
After reading RFC 2070 I learned there was a recent breaking change for no_std
/embedded programs. While it's recommended that I use the #[panic_implementation]
attributes, a recently added feature, I still receive an error, doing so like:
#[panic_implementation] #[no_mangle] pub extern fn panic_fmt() -> ! { loop{} }
Gives the error:
error[E0658]: #[panic_implementation] is an unstable feature (see issue #44489)
--> src/lang_items.rs:4:1
|
4 | #[panic_implementation] #[no_mangle] pub extern fn panic_fmt() -> ! { loop{} }
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(panic_implementation)] to the crate attributes to enable
Following their suggestion of adding #![feature(panic_implementation)]
to the top of the lang_items.rs
file doesn't seem to do the trick, as I'm getting the same error. How do I enable this unstable feature properly so that I can compile this no_std
application with behavior for panic!
defined?