diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -84,7 +84,9 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { }; for dyn_supertrait in &method_attrs.dynamized_supertraits { - if !trait_bounds(&original_trait.supertraits).any(|t| t.path.is_ident(dyn_supertrait)) { + if !trait_bounds(&original_trait.supertraits) + .any(|t| t.path.segments[0].ident == *dyn_supertrait) + { return abort!( dyn_supertrait.span(), "this trait definition has no such supertrait" @@ -206,14 +208,14 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { .iter() .filter_map(|t| { if let TypeParamBound::Trait(trait_bound) = t { - if let Some(ident) = trait_bound.path.get_ident() { - if ident == "Sized" { - return None; - } else if method_attrs.dynamized_supertraits.contains(ident) { - let mut bound = trait_bound.clone(); - bound.path.segments[0].ident = format_ident!("Dyn{}", ident); - return Some(TypeParamBound::Trait(bound)); - } + if trait_bound.path.is_ident("Sized") { + return None; + } + let ident = &trait_bound.path.segments[0].ident; + if method_attrs.dynamized_supertraits.contains(ident) { + let mut bound = trait_bound.clone(); + bound.path.segments[0].ident = format_ident!("Dyn{}", ident); + return Some(TypeParamBound::Trait(bound)); } } Some(t.clone()) |