This commit is contained in:
James Wilson
2025-06-03 12:07:46 +01:00
parent b34e449adf
commit fb20b01af6
4 changed files with 26 additions and 3 deletions
+12 -1
View File
@@ -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);