Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub fn expand_metadata(def: &Def) -> TokenStream2 {
syn::ReturnType::Default => quote!(#scale_info::meta_type::<()>()),
syn::ReturnType::Type(_, ty) => {
let mut ty = ty.clone();
// Replace Self::AssociatedType with Impl::AssociatedType
replacer.visit_type_mut(&mut ty);
quote!(#scale_info::meta_type::<#ty>())
}
Expand Down Expand Up @@ -73,12 +74,12 @@ pub fn expand_metadata(def: &Def) -> TokenStream2 {
}
}

// Convert `Self::AssociatedType` to `Impl::AssociatedType`
// Replace `Self` with `Impl` in the type path
struct AssociatedTypeReplacer;
impl syn::visit_mut::VisitMut for AssociatedTypeReplacer {
fn visit_path_mut(&mut self, path: &mut syn::Path) {
if path.segments.len() == 2 && path.segments[0].ident == "Self" {
path.segments[0].ident = syn::Ident::new("Impl", path.segments[0].ident.span());
fn visit_ident_mut(&mut self, ident: &mut syn::Ident) {
if ident == "Self" {
*ident = syn::Ident::new("Impl", ident.span());
}
}
}
Loading