diff --git a/impl/src/generics.rs b/impl/src/generics.rs index 254c2ed..26fe0a9 100644 --- a/impl/src/generics.rs +++ b/impl/src/generics.rs @@ -25,11 +25,12 @@ impl<'a> ParamsInScope<'a> { fn crawl(in_scope: &ParamsInScope, ty: &Type, found: &mut bool) { if let Type::Path(ty) = ty { - if ty.qself.is_none() { - if let Some(ident) = ty.path.get_ident() { - if in_scope.names.contains(ident) { - *found = true; - } + if let Some(qself) = &ty.qself { + crawl(in_scope, &qself.ty, found); + } else { + let front = ty.path.segments.first().unwrap(); + if front.arguments.is_none() && in_scope.names.contains(&front.ident) { + *found = true; } } for segment in &ty.path.segments { diff --git a/tests/test_generics.rs b/tests/test_generics.rs index 36f1181..bcbfee0 100644 --- a/tests/test_generics.rs +++ b/tests/test_generics.rs @@ -1,6 +1,7 @@ #![allow(clippy::needless_late_init, clippy::uninlined_format_args)] use core::fmt::{self, Debug, Display}; +use core::str::FromStr; use thiserror::Error; pub struct NoFormat; @@ -160,6 +161,24 @@ pub struct StructFromGeneric { #[error(transparent)] pub struct StructTransparentGeneric(pub E); +// Should expand to: +// +// impl Display for AssociatedTypeError +// where +// T::Err: Display; +// +// impl Error for AssociatedTypeError +// where +// Self: Debug + Display; +// +#[derive(Error, Debug)] +pub enum AssociatedTypeError { + #[error("couldn't parse matrix")] + Other, + #[error("couldn't parse entry: {0}")] + EntryParseError(T::Err), +} + // Regression test for https://github.com/dtolnay/thiserror/issues/345 #[test] fn test_no_bound_on_named_fmt() {