Skip to content

Commit d378451

Browse files
committed
embedded: Remove error handler
Seems we no longer need an explicit error handler, remove it. I did not grok the reason (long thread link below) but just removed it and checked that the embedded crates still ran correctly. rust-lang/rust#51540)
1 parent 967b58d commit d378451

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

bitcoin/embedded/src/main.rs

-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern crate bitcoin;
88

99
use alloc::string::ToString;
1010
use alloc::vec;
11-
use core::alloc::Layout;
1211
use core::panic::PanicInfo;
1312

1413
use alloc_cortex_m::CortexMHeap;
@@ -17,7 +16,6 @@ use bitcoin::{Address, Network, PrivateKey};
1716
use bitcoin::secp256k1::ffi::types::AlignedType;
1817
use bitcoin::secp256k1::Secp256k1;
1918

20-
use cortex_m::asm;
2119
use cortex_m_rt::entry;
2220
use cortex_m_semihosting::{debug, hprintln};
2321

@@ -57,16 +55,6 @@ fn main() -> ! {
5755
loop {}
5856
}
5957

60-
// define what happens in an Out Of Memory (OOM) condition
61-
#[alloc_error_handler]
62-
fn alloc_error(_layout: Layout) -> ! {
63-
hprintln!("alloc error").unwrap();
64-
debug::exit(debug::EXIT_FAILURE);
65-
asm::bkpt();
66-
67-
loop {}
68-
}
69-
7058
#[inline(never)]
7159
#[panic_handler]
7260
fn panic(info: &PanicInfo) -> ! {

hashes/embedded/src/main.rs

-11
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ extern crate bitcoin_hashes;
77

88
#[cfg(feature = "alloc")] extern crate alloc;
99
#[cfg(feature = "alloc")] use alloc_cortex_m::CortexMHeap;
10-
#[cfg(feature = "alloc")] use core::alloc::Layout;
11-
#[cfg(feature = "alloc")] use cortex_m::asm;
1210
#[cfg(feature = "alloc")] use alloc::string::ToString;
1311

1412
use bitcoin_hashes::{sha256, Hash, HashEngine};
@@ -63,12 +61,3 @@ fn check_result(engine: sha256::HashEngine) {
6361
debug::exit(debug::EXIT_FAILURE);
6462
}
6563
}
66-
67-
// define what happens in an Out Of Memory (OOM) condition
68-
#[cfg(feature = "alloc")]
69-
#[alloc_error_handler]
70-
fn alloc_error(_layout: Layout) -> ! {
71-
asm::bkpt();
72-
73-
loop {}
74-
}

0 commit comments

Comments
 (0)