From 33a0e6ec4cc890995f45d60e04cd3efa8025b824 Mon Sep 17 00:00:00 2001 From: Julius Rakow Date: Sat, 25 Aug 2018 00:43:42 +0200 Subject: [PATCH] disable std::error in no_std --- src/common/stack.rs | 2 ++ src/lib.rs | 3 +++ src/validation/mod.rs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/common/stack.rs b/src/common/stack.rs index 2366adb..9479fc5 100644 --- a/src/common/stack.rs +++ b/src/common/stack.rs @@ -1,4 +1,5 @@ +#[cfg(feature = "std")] use std::error; use std::fmt; @@ -11,6 +12,7 @@ impl fmt::Display for Error { } } +#[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str { &self.0 diff --git a/src/lib.rs b/src/lib.rs index 83b47da..7c86318 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,6 +110,7 @@ extern crate memory_units as memory_units_crate; pub extern crate nan_preserving_float; use std::fmt; +#[cfg(feature = "std")] use std::error; /// Error type which can be thrown by wasm code or by host environment. @@ -139,6 +140,7 @@ impl fmt::Display for Trap { } } +#[cfg(feature = "std")] impl error::Error for Trap { fn description(&self) -> &str { "runtime trap" @@ -309,6 +311,7 @@ impl fmt::Display for Error { } } +#[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str { match *self { diff --git a/src/validation/mod.rs b/src/validation/mod.rs index 1620009..ed6f8ee 100644 --- a/src/validation/mod.rs +++ b/src/validation/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "std")] use std::error; use std::fmt; use hashmap_core::HashSet; @@ -27,6 +28,7 @@ impl fmt::Display for Error { } } +#[cfg(feature = "std")] impl error::Error for Error { fn description(&self) -> &str { &self.0