diff options
-rw-r--r-- | src/lib.rs | 62 |
1 files changed, 32 insertions, 30 deletions
@@ -72,6 +72,11 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { for item in &original_trait.items { if let TraitItem::Type(assoc_type) = item { match parse_assoc_type(assoc_type) { + Ok((ident, type_)) => { + type_converter + .assoc_type_conversions + .insert(ident.clone(), type_); + } Err((_, AssocTypeError::NoTraitBound)) => continue, Err((span, AssocTypeError::TraitBoundContainsAssocType)) => { return abort!(span, "dynamize does not support associated types here") @@ -82,11 +87,6 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { "dynamize does not (yet?) support generic associated types" ) } - Ok((ident, type_)) => { - type_converter - .assoc_type_conversions - .insert(ident.clone(), type_); - } } } } @@ -95,32 +95,34 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { if let TraitItem::Method(method) = item { let mut signature = method.sig.clone(); match parse_trait_signature(&mut signature, &type_converter) { - Err((_, MethodError::NonDispatchableMethod)) => continue, - Err((span, MethodError::Transform(TransformError::AssocTypeWithoutDestType))) => { - return abort!( - span, - "associated type is either undefined or doesn't have a trait bound" - ) - } - Err((span, MethodError::AssocTypeInInputs)) => { - return abort!( - span, - "dynamize does not support associated types in parameter types" - ) - } - Err((span, MethodError::Transform(TransformError::UnsupportedType))) => { - return abort!(span, "dynamize does not know how to convert this type") - } - Err((span, MethodError::UnconvertedAssocType)) => { - return abort!(span, "dynamize does not support associated types here") - } - Err((span, MethodError::ImplTraitInInputs)) => { - return abort!( - span, - "dynamize does not support impl here, change it to a method generic" - ) - } Ok(parsed_method) => objectifiable_methods.push((signature, parsed_method)), + Err((span, err)) => match err { + MethodError::NonDispatchableMethod => continue, + MethodError::AssocTypeInInputs => { + return abort!( + span, + "dynamize does not support associated types in parameter types" + ) + } + MethodError::ImplTraitInInputs => { + return abort!( + span, + "dynamize does not support impl here, change it to a method generic" + ) + } + MethodError::Transform(TransformError::AssocTypeWithoutDestType) => { + return abort!( + span, + "associated type is either undefined or doesn't have a trait bound" + ) + } + MethodError::Transform(TransformError::UnsupportedType) => { + return abort!(span, "dynamize does not know how to convert this type") + } + MethodError::UnconvertedAssocType => { + return abort!(span, "dynamize does not support associated types here") + } + }, }; } } |