diff --git a/Cargo.lock b/Cargo.lock index 5affebc76fdeb..5584971260cd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2848,6 +2848,7 @@ dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", + "expander", "frame-support-procedural-tools", "itertools", "macro_magic", diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index a2823463c5d67..f8c6b9393f08d 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -25,6 +25,7 @@ syn = { version = "2.0.16", features = ["full"] } frame-support-procedural-tools = { version = "4.0.0-dev", path = "./tools" } proc-macro-warning = { version = "0.4.1", default-features = false } macro_magic = { version = "0.3.5", features = ["proc_support"] } +expander = "2.0.0" [features] default = ["std"] diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 958a10e7242dc..9879a65d684a6 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -178,7 +178,15 @@ pub fn construct_runtime(input: TokenStream) -> TokenStream { .and_then(|_| construct_runtime_final_expansion(explicit_decl)), }; - res.unwrap_or_else(|e| e.to_compile_error()).into() + let res = res.unwrap_or_else(|e| e.to_compile_error()); + + let res = expander::Expander::new("construct_runtime") + .dry(std::env::var("FRAME_EXPAND").is_err()) + .verbose(true) + .write_to_out_dir(res) + .expect("Does not fail because of IO in OUT_DIR; qed"); + + res.into() } /// When some pallet have implicit parts definition then the macro will expand into a macro call to