From 95f2528cbf75cf73b102f6c4a19fed3b2208feb7 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 11 May 2022 20:19:09 +0200 Subject: [PATCH] Remove install_panic_handler from non-wasm32 builds --- packages/std/src/panic.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/std/src/panic.rs b/packages/std/src/panic.rs index 1497caf816..7ca619e31a 100644 --- a/packages/std/src/panic.rs +++ b/packages/std/src/panic.rs @@ -1,18 +1,14 @@ -/// When compiled to Wasm, this installs a panic handler that aborts the -/// contract execution and sends the panic message and location to the host. -/// For other targets, this is a noop. +/// Installs a panic handler that aborts the contract execution +/// and sends the panic message and location to the host. /// /// This overrides any previous panic handler. See /// for details. -#[cfg(feature = "abort")] +#[cfg(all(feature = "abort", target_arch = "wasm32"))] pub fn install_panic_handler() { - #[cfg(target_arch = "wasm32")] - { - use super::imports::handle_panic; - std::panic::set_hook(Box::new(|info| { - // E.g. "panicked at 'oh no (a = 3)', src/contract.rs:51:5" - let full_message = info.to_string(); - handle_panic(&full_message); - })); - } + use super::imports::handle_panic; + std::panic::set_hook(Box::new(|info| { + // E.g. "panicked at 'oh no (a = 3)', src/contract.rs:51:5" + let full_message = info.to_string(); + handle_panic(&full_message); + })); }