mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
De-dup types early in CLI/macro so that derives/substitutes work for de-duped types (#2015)
* De-dup types early to enable derives for them * ensure_unique_type_paths in CLI codegen, too * Update UI test outpuot --------- Co-authored-by: José Duarte <duarte.gmj@gmail.com>
This commit is contained in:
+12
-1
@@ -102,7 +102,17 @@ fn subxt_inner(args: TokenStream, item_mod: syn::ItemMod) -> Result<TokenStream,
|
||||
.map_err(|e| TokenStream::from(e.write_errors()))?;
|
||||
|
||||
// Fetch metadata first, because we need it to validate some of the chosen codegen options.
|
||||
let metadata = fetch_metadata(&args)?;
|
||||
let metadata = {
|
||||
let mut metadata = fetch_metadata(&args)?;
|
||||
|
||||
// Run this first to ensure type paths are unique (which may result in 1,2,3 suffixes being added
|
||||
// to type paths), so that when we validate derives/substitutions below, they are allowed for such
|
||||
// types. See <https://github.com/paritytech/subxt/issues/2011>.
|
||||
scale_typegen::utils::ensure_unique_type_paths(metadata.types_mut())
|
||||
.expect("ensure_unique_type_paths should not fail; please report an issue.");
|
||||
|
||||
metadata
|
||||
};
|
||||
|
||||
let mut codegen = CodegenBuilder::new();
|
||||
|
||||
@@ -135,6 +145,7 @@ fn subxt_inner(args: TokenStream, item_mod: syn::ItemMod) -> Result<TokenStream,
|
||||
.into_iter()
|
||||
.collect(),
|
||||
);
|
||||
|
||||
for d in args.derive_for_type {
|
||||
validate_type_path(&d.path.path, &metadata);
|
||||
codegen.add_derives_for_type(d.path, d.derive.into_iter(), d.recursive);
|
||||
|
||||
Reference in New Issue
Block a user