diff --git a/dash/Cargo.toml b/dash/Cargo.toml index a69ed823a..84cf907d6 100644 --- a/dash/Cargo.toml +++ b/dash/Cargo.toml @@ -40,8 +40,8 @@ test-utils = [] # The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. # Instead no-std enables additional features required for this crate to be usable without std. # As a result, both can be enabled without conflict. -std = ["secp256k1/std", "dashcore_hashes/std", "bech32/std", "internals/std"] -no-std = ["core2", "dashcore_hashes/alloc", "dashcore_hashes/core2", "secp256k1/alloc"] +std = ["secp256k1/std", "bech32/std", "internals/std"] +no-std = ["core2", "secp256k1/alloc"] [package.metadata.docs.rs] all-features = true @@ -50,7 +50,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] internals = { path = "../internals", package = "dashcore-private" } bech32 = { version = "0.9.1", default-features = false } -dashcore_hashes = { path = "../hashes", default-features = false } +dashcore_hashes = { path = "../hashes" } secp256k1 = { default-features = false, features = ["hashes"], version= "0.30.0" } core2 = { version = "0.4.0", optional = true, features = ["alloc"], default-features = false } rustversion = { version="1.0.20"} diff --git a/hashes/Cargo.toml b/hashes/Cargo.toml index 77287370e..1fc5ceb9f 100644 --- a/hashes/Cargo.toml +++ b/hashes/Cargo.toml @@ -13,9 +13,7 @@ edition = "2021" exclude = ["tests", "contrib"] [features] -default = ["std"] -std = ["alloc", "internals/std"] -alloc = ["internals/alloc"] +default = ["internals/alloc"] schemars = ["actual-schemars"] serde-std = ["serde/std"] x11 = ["rs-x11-hash"] @@ -27,7 +25,6 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] internals = { path = "../internals", package = "dashcore-private" } -core2 = { version = "0.4.0", default-features = false, optional = true } # Only enable this if you explicitly do not want to use "std", otherwise enable "serde-std". serde = { version = "1.0.219", default-features = false, optional = true } # Do NOT use this as a feature! Use the `schemars` feature instead. Can only be used with "std" enabled. diff --git a/hashes/src/error.rs b/hashes/src/error.rs index 251258cfa..2614d26b6 100644 --- a/hashes/src/error.rs +++ b/hashes/src/error.rs @@ -36,7 +36,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::Error::*; diff --git a/hashes/src/hash160.rs b/hashes/src/hash160.rs index 997c44800..3262026d2 100644 --- a/hashes/src/hash160.rs +++ b/hashes/src/hash160.rs @@ -49,12 +49,10 @@ fn from_engine(e: HashEngine) -> Hash { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{hash160, Hash, HashEngine}; #[derive(Clone)] - #[cfg(feature = "alloc")] struct Test { input: Vec, output: Vec, diff --git a/hashes/src/hash_x11.rs b/hashes/src/hash_x11.rs index 57a9675be..bedeb9670 100644 --- a/hashes/src/hash_x11.rs +++ b/hashes/src/hash_x11.rs @@ -21,16 +21,9 @@ use core::ops::Index; use core::slice::SliceIndex; use core::str; -#[cfg(feature = "std")] use std::io; -#[cfg(feature = "std")] use std::vec::Vec; -#[cfg(all(feature = "core2", not(feature = "std")))] -use core2::io; - -#[cfg(all(feature = "alloc", not(feature = "std")))] -use crate::alloc::vec::Vec; use crate::{hex, Error, HashEngine as _}; crate::internal_macros::hash_type! { diff --git a/hashes/src/hex.rs b/hashes/src/hex.rs index f5b648b44..62fa9e08c 100644 --- a/hashes/src/hex.rs +++ b/hashes/src/hex.rs @@ -16,15 +16,8 @@ //! use core::{fmt, str}; -#[cfg(feature = "std")] use std::io; -#[cfg(all(feature = "core2", not(feature = "std")))] -use core2::io; - -#[cfg(all(feature = "alloc", not(feature = "std")))] -use crate::alloc::vec::Vec; - /// Hex decoding error. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Error { @@ -48,7 +41,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::Error::*; @@ -119,7 +111,6 @@ impl<'a> Iterator for HexIterator<'a> { } } -#[cfg(any(feature = "std", feature = "core2"))] impl<'a> io::Read for HexIterator<'a> { fn read(&mut self, buf: &mut [u8]) -> io::Result { let mut bytes_read = 0usize; @@ -146,7 +137,6 @@ impl<'a> DoubleEndedIterator for HexIterator<'a> { impl<'a> ExactSizeIterator for HexIterator<'a> {} -#[cfg(any(test, feature = "std", feature = "alloc"))] impl FromHex for Vec { fn from_byte_iter(iter: I) -> Result where @@ -200,7 +190,6 @@ impl_fromhex_array!(384); impl_fromhex_array!(512); #[cfg(test)] -#[cfg(feature = "alloc")] mod tests { use internals::hex::exts::DisplayHex; diff --git a/hashes/src/hmac.rs b/hashes/src/hmac.rs index 46b374de9..a01e77f95 100644 --- a/hashes/src/hmac.rs +++ b/hashes/src/hmac.rs @@ -244,7 +244,6 @@ impl<'de, T: Hash + Deserialize<'de>> Deserialize<'de> for Hmac { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{sha256, Hash, HashEngine, Hmac, HmacEngine}; diff --git a/hashes/src/impls.rs b/hashes/src/impls.rs index c63605e57..15e61e5b8 100644 --- a/hashes/src/impls.rs +++ b/hashes/src/impls.rs @@ -12,17 +12,8 @@ // If not, see . // -//! `std` / `core2` Impls. -//! -//! Implementations of traits defined in `std` / `core2` and not in `core`. -//! - -#[cfg(feature = "std")] use std::io; -#[cfg(not(feature = "std"))] -use core2::io; - use crate::{hmac, ripemd160, sha1, sha256, sha512, siphash24, HashEngine}; impl io::Write for sha1::HashEngine { diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 233175eb2..be5153cdc 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -88,16 +88,9 @@ // that don't do anything but annoy us and cant actually ever be resolved. #![allow(bare_trait_objects)] #![allow(ellipsis_inclusive_range_patterns)] -#![cfg_attr(all(not(test), not(feature = "std")), no_std)] // Instead of littering the codebase for non-fuzzing code just globally allow. #![cfg_attr(fuzzing, allow(dead_code, unused_imports))] -#[cfg(all(feature = "alloc", not(feature = "std")))] -extern crate alloc; -#[cfg(any(test, feature = "std"))] -extern crate core; -#[cfg(feature = "core2")] -extern crate core2; #[cfg(feature = "serde")] pub extern crate serde; #[cfg(all(test, feature = "serde"))] @@ -129,7 +122,6 @@ pub mod hash160; pub mod hash_x11; pub mod hex; pub mod hmac; -#[cfg(any(feature = "std", feature = "core2"))] mod impls; pub mod ripemd160; pub mod sha1; diff --git a/hashes/src/ripemd160.rs b/hashes/src/ripemd160.rs index 87551058e..be9fbca67 100644 --- a/hashes/src/ripemd160.rs +++ b/hashes/src/ripemd160.rs @@ -405,7 +405,6 @@ impl HashEngine { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use std::convert::TryFrom; diff --git a/hashes/src/sha1.rs b/hashes/src/sha1.rs index e77d69432..9d060de42 100644 --- a/hashes/src/sha1.rs +++ b/hashes/src/sha1.rs @@ -144,7 +144,6 @@ impl HashEngine { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{sha1, Hash, HashEngine}; diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 7e9e83704..51ce18397 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -520,7 +520,6 @@ mod tests { use crate::{sha256, Hash, HashEngine}; #[test] - #[cfg(feature = "alloc")] fn test() { #[derive(Clone)] struct Test { diff --git a/hashes/src/sha256d.rs b/hashes/src/sha256d.rs index 611cea5e4..8bbd5755f 100644 --- a/hashes/src/sha256d.rs +++ b/hashes/src/sha256d.rs @@ -44,7 +44,6 @@ fn from_engine(e: sha256::HashEngine) -> Hash { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{sha256, sha256d, Hash, HashEngine}; diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index e5a0dba69..d2e1b0c06 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -184,7 +184,6 @@ macro_rules! sha256t_hash_newtype_tag_constructor { #[cfg(test)] mod tests { - #[cfg(feature = "alloc")] use crate::Hash; use crate::{sha256, sha256t}; @@ -206,7 +205,6 @@ mod tests { } /// A hash tagged with `$name`. - #[cfg(feature = "alloc")] pub type TestHash = sha256t::Hash; sha256t_hash_newtype! { @@ -219,7 +217,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_sha256t() { assert_eq!( TestHash::hash(&[0]).to_string(), diff --git a/hashes/src/sha512.rs b/hashes/src/sha512.rs index bebc026d6..5f1a79ff2 100644 --- a/hashes/src/sha512.rs +++ b/hashes/src/sha512.rs @@ -271,7 +271,6 @@ impl HashEngine { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{sha512, Hash, HashEngine}; diff --git a/hashes/src/sha512_256.rs b/hashes/src/sha512_256.rs index 2d24ffbb9..3d7343f36 100644 --- a/hashes/src/sha512_256.rs +++ b/hashes/src/sha512_256.rs @@ -88,7 +88,6 @@ fn from_engine(e: HashEngine) -> Hash { #[cfg(test)] mod tests { #[test] - #[cfg(feature = "alloc")] fn test() { use crate::{sha512_256, Hash, HashEngine}; diff --git a/key-wallet-manager/Cargo.toml b/key-wallet-manager/Cargo.toml index 78e7bbe6c..aa544b149 100644 --- a/key-wallet-manager/Cargo.toml +++ b/key-wallet-manager/Cargo.toml @@ -10,7 +10,7 @@ license = "CC0-1.0" [features] default = ["std", "bincode"] -std = ["key-wallet/std", "dashcore/std", "dashcore_hashes/std", "secp256k1/std"] +std = ["key-wallet/std", "dashcore/std", "secp256k1/std"] serde = ["dep:serde", "key-wallet/serde", "dashcore/serde"] getrandom = ["key-wallet/getrandom"] bincode = ["dep:bincode", "key-wallet/bincode"] @@ -19,7 +19,7 @@ test-utils = [] [dependencies] key-wallet = { path = "../key-wallet", default-features = false } dashcore = { path = "../dash", default-features = false } -dashcore_hashes = { path = "../hashes", default-features = false } +dashcore_hashes = { path = "../hashes" } secp256k1 = { version = "0.30.0", default-features = false, features = ["recovery"] } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } async-trait = "0.1" diff --git a/key-wallet/Cargo.toml b/key-wallet/Cargo.toml index fb65893f9..80c633a91 100644 --- a/key-wallet/Cargo.toml +++ b/key-wallet/Cargo.toml @@ -10,7 +10,7 @@ license = "CC0-1.0" [features] default = ["std"] -std = ["dashcore_hashes/std", "secp256k1/std", "bip39/std", "getrandom", "rand"] +std = ["secp256k1/std", "bip39/std", "getrandom", "rand"] serde = ["dep:serde", "dep:serde_json", "dashcore_hashes/serde", "secp256k1/serde", "dashcore/serde"] bincode = ["serde", "dep:bincode", "dep:bincode_derive", "dashcore_hashes/bincode", "dashcore/bincode"] bip38 = ["scrypt", "aes", "bs58", "rand"] @@ -20,7 +20,7 @@ test-utils = ["dashcore/test-utils"] [dependencies] internals = { path = "../internals", package = "dashcore-private" } -dashcore_hashes = { path = "../hashes", default-features = false } +dashcore_hashes = { path = "../hashes" } dashcore = { path="../dash" } secp256k1 = { version = "0.30.0", default-features = false, features = ["hashes", "recovery"] } bip39 = { version = "2.2.0", default-features = false, features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "portuguese", "spanish", "zeroize"] }