diff options
Diffstat (limited to 'src/transform.rs')
-rw-r--r-- | src/transform.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/transform.rs b/src/transform.rs index 8de4c96..594d383 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use proc_macro2::Span; use quote::quote; use syn::{ - spanned::Spanned, GenericArgument, Generics, Ident, PathArguments, TraitBound, Type, + spanned::Spanned, GenericArgument, Generics, Ident, PathArguments, QSelf, TraitBound, Type, TypeParamBound, TypePath, TypeReference, TypeTraitObject, WherePredicate, }; @@ -11,6 +11,7 @@ use crate::{ filter_map_assoc_paths, match_assoc_type, parse_assoc_type::{BoxType, DestType}, parse_trait_sig::{MethodError, TypeTransform}, + path_is_assoc_type, syn_utils::{iter_path, iter_type, type_arguments_mut}, }; @@ -26,6 +27,7 @@ pub enum TransformError { UnsupportedType, ExpectedAtLeastNTypes(usize), AssocTypeAfterFirstNTypes(usize, Ident), + QualifiedSelfAssociatedType, } impl TypeConverter<'_> { @@ -57,6 +59,17 @@ impl TypeConverter<'_> { } pub fn convert_type(&self, type_: &mut Type) -> Result<TypeTransform, (Span, TransformError)> { + if let Type::Path(TypePath { + qself: Some(QSelf { ty, .. }), + .. + }) = type_ + { + if let Type::Path(TypePath { qself: None, path }) = ty.as_ref() { + if path_is_assoc_type(path) { + return Err((path.span(), TransformError::QualifiedSelfAssociatedType)); + } + } + } if !iter_type(type_).any(match_assoc_type) { return Ok(TypeTransform::NoOp); } |