From 79ff6d3cd0602399f3bdc6ac8d52f4c6983e5cb8 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 19 Nov 2021 12:14:01 +0100 Subject: better error for assoc types in trait generic bounds --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 99abfdb..abeab4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,6 +43,8 @@ use crate::parse_trait_sig::parse_trait_signature; use crate::parse_trait_sig::MethodParseError; use crate::parse_trait_sig::SignatureChanges; use crate::parse_trait_sig::TypeTransform; +use crate::syn_utils::find_in_path; +use crate::syn_utils::trait_bounds; use crate::transform::AssocTypeConversions; mod parse_assoc_type; @@ -179,6 +181,14 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { for generic in &dyn_trait.generics.params { if let GenericParam::Type(type_param) = generic { generic_map.insert(type_param.ident.clone(), type_param.bounds.clone()); + for trait_bound in trait_bounds(&type_param.bounds) { + if let Some(assoc_type) = find_in_path(&trait_bound.path, &AssocTypeMatcher) { + return abort!( + assoc_type.span(), + "dynamize does not support associated types in trait generic bounds" + ); + } + } } } -- cgit v1.2.3