diff --git a/Cargo.lock b/Cargo.lock index d9cb87af47edd..685171fd1df16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2700,6 +2700,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", + "sp-debug-derive", "sp-inherents", "sp-io", "sp-runtime", diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index d8b1b9c248720..6ed67c8081b5b 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -27,6 +27,7 @@ sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../pri sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } sp-weights = { version = "4.0.0", default-features = false, path = "../../primitives/weights" } +sp-debug-derive = { default-features = false, path = "../../primitives/debug-derive" } tt-call = "1.0.8" frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" } paste = "1.0" @@ -75,7 +76,9 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks" ] -try-runtime = [] +try-runtime = [ + "sp-debug-derive/force-debug" +] # By default some types have documentation, `no-metadata-docs` allows to reduce the documentation # in the metadata. no-metadata-docs = ["frame-support-procedural/no-metadata-docs", "sp-api/no-metadata-docs"] diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 895b09a17e083..b8aa5674ddde5 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -648,12 +648,13 @@ pub fn derive_debug_no_bound(input: TokenStream) -> TokenStream { } /// Derive [`Debug`], if `std` is enabled it uses `frame_support::DebugNoBound`, if `std` is not -/// enabled it just returns `""`. +/// enabled it just returns `""`. /// This behaviour is useful to prevent bloating the runtime WASM blob from unneeded code. #[proc_macro_derive(RuntimeDebugNoBound)] pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { - #[cfg(not(feature = "std"))] - { + if cfg!(any(feature = "std", feature = "try-runtime")) { + debug_no_bound::derive_debug_no_bound(input) + } else { let input: syn::DeriveInput = match syn::parse(input) { Ok(input) => input, Err(e) => return e.to_compile_error().into(), @@ -666,18 +667,13 @@ pub fn derive_runtime_debug_no_bound(input: TokenStream) -> TokenStream { const _: () = { impl #impl_generics core::fmt::Debug for #name #ty_generics #where_clause { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { - fmt.write_str("") + fmt.write_str("") } } }; ) .into() } - - #[cfg(feature = "std")] - { - debug_no_bound::derive_debug_no_bound(input) - } } /// Derive [`PartialEq`] but do not bound any generic. Docs are at