From 7ad3bb79f9d1646e0d45a80fd4f024241f89a402 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 27 Dec 2018 08:40:50 -1000 Subject: [PATCH] Fix trivial `no_std`-breaking issues. --- src/bssl.rs | 2 +- src/error.rs | 1 + src/lib.rs | 1 + src/rand.rs | 6 +++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bssl.rs b/src/bssl.rs index 8e60558b2c..7ab504a8cd 100644 --- a/src/bssl.rs +++ b/src/bssl.rs @@ -22,7 +22,7 @@ use crate::{c, error}; #[repr(transparent)] pub struct Result(c::int); -impl From for ::std::result::Result<(), error::Unspecified> { +impl From for core::result::Result<(), error::Unspecified> { fn from(ret: Result) -> Self { match ret.0 { 1 => Ok(()), diff --git a/src/error.rs b/src/error.rs index 30681f49f5..854d5b9a72 100644 --- a/src/error.rs +++ b/src/error.rs @@ -180,6 +180,7 @@ impl std::error::Error for KeyRejected { fn description(&self) -> &str { self.description_() } } +#[cfg(feature = "use_heap")] impl std::fmt::Display for KeyRejected { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.write_str(self.description_()) diff --git a/src/lib.rs b/src/lib.rs index 2e54be3eda..26c0af9c00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,6 +113,7 @@ mod rsa; pub mod signature; +#[cfg(any(test, feature = "use_heap"))] pub mod test; mod sealed { diff --git a/src/rand.rs b/src/rand.rs index 8baf521a2c..4912b8d718 100644 --- a/src/rand.rs +++ b/src/rand.rs @@ -93,7 +93,10 @@ impl SecureRandom for SystemRandom { impl sealed::Sealed for SystemRandom {} -#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "ios", windows)))] +#[cfg(all( + feature = "use_heap", + not(any(target_os = "linux", target_os = "macos", target_os = "ios", windows)) +))] use self::urandom::fill as fill_impl; #[cfg(any( @@ -182,6 +185,7 @@ mod sysrand { // Keep the `cfg` conditions in sync with the conditions in lib.rs. #[cfg(all( + feature = "use_heap", any(target_os = "redox", unix), not(any(target_os = "macos", target_os = "ios")), not(all(target_os = "linux", not(feature = "dev_urandom_fallback")))