From 299e8a9737259e6fd8052f3e520533f8fc3cd7f9 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 15 Jan 2018 16:21:26 -0500 Subject: [PATCH] lib/cretonne works with no_std --- lib/cretonne/Cargo.toml | 5 ++++- lib/cretonne/src/dbg.rs | 1 + lib/cretonne/src/lib.rs | 7 +++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/cretonne/Cargo.toml b/lib/cretonne/Cargo.toml index 91dc6ccdac..0cf3fffd9b 100644 --- a/lib/cretonne/Cargo.toml +++ b/lib/cretonne/Cargo.toml @@ -20,8 +20,11 @@ name = "cretonne" [dependencies.hashmap_core] version = "0.1.1" optional = true +[dependencies.error_core] +version = "0.1.0" +optional = true [features] # Currently, the only feature is the `no_std` feature. # Enabling this disables use of `stdlib`. -no_std = ["hashmap_core"] \ No newline at end of file +no_std = ["hashmap_core", "error_core"] \ No newline at end of file diff --git a/lib/cretonne/src/dbg.rs b/lib/cretonne/src/dbg.rs index cb8dd07118..7e5cd2777c 100644 --- a/lib/cretonne/src/dbg.rs +++ b/lib/cretonne/src/dbg.rs @@ -9,6 +9,7 @@ /// The output will appear in files named `cretonne.dbg.*`, where the suffix is named after the /// thread doing the logging. +#[cfg(not(feature = "no_std"))] use std::cell::RefCell; #[cfg(not(feature = "no_std"))] use std::env; diff --git a/lib/cretonne/src/lib.rs b/lib/cretonne/src/lib.rs index 2bed9df4fb..c448cc1d0f 100644 --- a/lib/cretonne/src/lib.rs +++ b/lib/cretonne/src/lib.rs @@ -9,6 +9,8 @@ #[cfg(feature = "no_std")] extern crate hashmap_core; #[cfg(feature = "no_std")] +extern crate error_core; +#[cfg(feature = "no_std")] #[macro_use] extern crate alloc; @@ -72,9 +74,6 @@ mod std { pub use alloc::BTreeSet; } pub mod error { - pub trait Error { - fn description(&self) -> &str; - fn cause(&self) -> Option<&Error> { None } - } + pub use error_core::Error; } } \ No newline at end of file