diff --git a/substrate/primitives/core/Cargo.toml b/substrate/primitives/core/Cargo.toml index f063b65c97..631bf3fc12 100644 --- a/substrate/primitives/core/Cargo.toml +++ b/substrate/primitives/core/Cargo.toml @@ -40,7 +40,7 @@ zeroize = { version = "1.4.2", default-features = false } secrecy = { version = "0.8.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.11.1", optional = true } -sp-debug-derive = { version = "3.0.0", path = "../debug-derive" } +sp-debug-derive = { version = "3.0.0", default-features = false, path = "../debug-derive" } sp-externalities = { version = "0.10.0-dev", optional = true, path = "../externalities" } sp-storage = { version = "4.0.0-dev", default-features = false, path = "../storage" } parity-util-mem = { version = "0.10.0", default-features = false, features = [ diff --git a/substrate/primitives/debug-derive/Cargo.toml b/substrate/primitives/debug-derive/Cargo.toml index 2e5ef93e41..ce49c54b46 100644 --- a/substrate/primitives/debug-derive/Cargo.toml +++ b/substrate/primitives/debug-derive/Cargo.toml @@ -22,6 +22,12 @@ syn = "1.0.80" proc-macro2 = "1.0" [features] +default = [ "std" ] std = [] +# By default `RuntimeDebug` implements `Debug` that outputs `` when `std` is +# disabled. However, sometimes downstream users need to have the real `Debug` implementation for +# debugging purposes. If this is required, a user only needs to add this crate as a dependency of +# their runtime and enable the `force-debug` feature. +force-debug = [] [dev-dependencies] diff --git a/substrate/primitives/debug-derive/src/impls.rs b/substrate/primitives/debug-derive/src/impls.rs index 4d79ee9880..0e67ef81bc 100644 --- a/substrate/primitives/debug-derive/src/impls.rs +++ b/substrate/primitives/debug-derive/src/impls.rs @@ -43,7 +43,7 @@ pub fn debug_derive(ast: DeriveInput) -> proc_macro::TokenStream { gen.into() } -#[cfg(not(feature = "std"))] +#[cfg(all(not(feature = "std"), not(feature = "force-debug")))] mod implementation { use super::*; @@ -58,7 +58,7 @@ mod implementation { } } -#[cfg(feature = "std")] +#[cfg(any(feature = "std", feature = "force-debug"))] mod implementation { use super::*; use proc_macro2::Span; diff --git a/substrate/primitives/storage/Cargo.toml b/substrate/primitives/storage/Cargo.toml index 1a05fb9969..078e0fff12 100644 --- a/substrate/primitives/storage/Cargo.toml +++ b/substrate/primitives/storage/Cargo.toml @@ -18,9 +18,9 @@ sp-std = { version = "4.0.0-dev", default-features = false, path = "../std" } serde = { version = "1.0.126", optional = true, features = ["derive"] } impl-serde = { version = "0.3.1", optional = true } ref-cast = "1.0.0" -sp-debug-derive = { version = "3.0.0", path = "../debug-derive" } +sp-debug-derive = { version = "3.0.0", default-features = false, path = "../debug-derive" } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } [features] default = [ "std" ] -std = [ "sp-std/std", "serde", "impl-serde", "codec/std" ] +std = [ "sp-std/std", "serde", "impl-serde", "codec/std", "sp-debug-derive/std" ]