diff --git a/src/gen.rs b/src/gen.rs index 6c61815..99c776d 100644 --- a/src/gen.rs +++ b/src/gen.rs @@ -609,10 +609,10 @@ fn gen_type_item( // We simply use the associated type from our type parameter. let assoc_name = &item.ident; let attrs = filter_attrs(&item.attrs); - let generics = &item.generics; + let (impl_generics, type_generics, where_clause) = item.generics.split_for_impl(); Ok(quote! { - #(#attrs)* type #assoc_name #generics = #proxy_ty_param::#assoc_name #generics; + #(#attrs)* type #assoc_name #impl_generics = #proxy_ty_param::#assoc_name #type_generics #where_clause; }) } diff --git a/tests/compile-pass/associated_type_with_where_clause_for_all_refs.rs b/tests/compile-pass/associated_type_with_where_clause_for_all_refs.rs new file mode 100644 index 0000000..8990928 --- /dev/null +++ b/tests/compile-pass/associated_type_with_where_clause_for_all_refs.rs @@ -0,0 +1,22 @@ +use auto_impl::auto_impl; + +#[auto_impl(Arc, Box, Rc, &, &mut)] +trait HasAssociatedTypeWithBounds { + type AssociatedType<'a, T: From + 'a>; +} + +#[auto_impl(Arc, Box, Rc, &, &mut)] +trait HasAssociatedTypeWithBoundsAndWhereClause { + type AssociatedType<'a, T> + where + T: From + 'a; +} + +#[auto_impl(Arc, Box, Rc, &, &mut)] +trait HasAssociatedTypeWithRedundantBoundsAndWhereClause { + type AssociatedType<'a, T: From + 'a> + where + T: From + 'a; +} + +fn main() {}