@@ -50,12 +50,9 @@ infrastructure. Nevertheless, `wee_alloc` is also usable with `std`.
5050// We aren't using the standard library.
5151#![no_std]
5252
53- // Required to replace the global allocator.
54- #![feature(global_allocator)]
55-
5653// Required to use the `alloc` crate and its types, the `abort` intrinsic, and a
5754// custom panic handler.
58- #![feature(alloc, core_intrinsics, lang_items)]
55+ #![feature(alloc, core_intrinsics, panic_implementation, lang_items)]
5956
6057extern crate alloc;
6158extern crate wee_alloc;
@@ -64,18 +61,22 @@ extern crate wee_alloc;
6461#[global_allocator]
6562static ALLOC : wee_alloc :: WeeAlloc = wee_alloc :: WeeAlloc :: INIT ;
6663
67- // Need to provide a tiny `panic_fmt` lang-item implementation for `#![no_std]`.
68- // This implementation will translate panics into traps in the resulting
69- // WebAssembly.
70- #[lang = " panic_fmt" ]
71- extern " C" fn panic_fmt (
72- _args : :: core :: fmt :: Arguments ,
73- _file : & 'static str ,
74- _line : u32
75- ) -> ! {
76- use core :: intrinsics;
64+ // Need to provide a tiny `panic` implementation for `#![no_std]`.
65+ // This translates into an `unreachable` instruction that will
66+ // raise a `trap` the WebAssembly execution if we panic at runtime.
67+ #[panic_implementation]
68+ fn panic (_info : & :: core :: panic :: PanicInfo ) -> ! {
69+ unsafe {
70+ :: core :: intrinsics :: abort ();
71+ }
72+ }
73+
74+ // Need to provide a tiny `oom` lang-item implementation for
75+ // `#![no_std]`.
76+ #[lang = " oom" ]
77+ extern " C" fn oom () -> ! {
7778 unsafe {
78- intrinsics :: abort ();
79+ :: core :: intrinsics :: abort ();
7980 }
8081}
8182
0 commit comments