fix the allocator example

This commit is contained in:
Jorge Aparicio
2018-08-02 21:37:39 -05:00
parent 01e9a597c1
commit b7884948b2

View File

@@ -10,6 +10,7 @@
//! --- //! ---
#![feature(alloc)] #![feature(alloc)]
#![feature(alloc_error_handler)]
#![feature(global_allocator)] #![feature(global_allocator)]
#![feature(lang_items)] #![feature(lang_items)]
#![no_main] #![no_main]
@@ -25,6 +26,7 @@ extern crate cortex_m_rt as rt;
extern crate cortex_m_semihosting as sh; extern crate cortex_m_semihosting as sh;
extern crate panic_semihosting; extern crate panic_semihosting;
use core::alloc::Layout;
use core::fmt::Write; use core::fmt::Write;
use alloc_cortex_m::CortexMHeap; use alloc_cortex_m::CortexMHeap;
@@ -54,9 +56,9 @@ fn main() -> ! {
} }
// define what happens in an Out Of Memory (OOM) condition // define what happens in an Out Of Memory (OOM) condition
#[lang = "oom"] #[alloc_error_handler]
#[no_mangle] #[no_mangle]
pub fn rust_oom() -> ! { pub fn alloc_error(layout: Layout) -> ! {
asm::bkpt(); asm::bkpt();
loop {} loop {}