From 3b5bcd098377b038aab4ffcb045d149b17e00534 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 8 Aug 2024 10:57:38 +1000 Subject: [PATCH] primitives: Fix alloc feature We have an `alloc` feature but we are unconditionally using `extern crate alloc`, this is broken - clearly we need to add a `no-std` build for `primitives` in CI. Feature gate the `alloc` crate. While we are at it just pull types in from `alloc` in the `prelude` - I have no idea why we do not do this in `bitcoin`? --- primitives/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 598783835..65074412e 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -18,6 +18,7 @@ #![allow(clippy::manual_range_contains)] // More readable than clippy's format. #![allow(clippy::needless_borrows_for_generic_args)] // https://github.com/rust-lang/rust-clippy/issues/12454 +#[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "std")] @@ -44,9 +45,6 @@ pub use self::sequence::Sequence; #[rustfmt::skip] #[allow(unused_imports)] mod prelude { - #[cfg(all(not(feature = "std"), not(test)))] + #[cfg(feature = "alloc")] pub use alloc::string::ToString; - - #[cfg(any(feature = "std", test))] - pub use std::string::ToString; }