From 74a29b912aaa14dbeb7e5c51ae11c61e733ef645 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 25 Nov 2021 13:44:20 +0100 Subject: better error for qualified associated types --- src/lib.rs | 3 +++ src/transform.rs | 4 ++++ ui-tests/src/bin/qualified_assoc_type.stderr | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4c1675c..fc559bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,6 +155,9 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { n ) } + MethodError::Transform(TransformError::QualifiedAssociatedType) => { + return abort!(span, "dynamize does not support qualified associated types") + } MethodError::Transform(TransformError::QualifiedSelfAssociatedType) => { return abort!(span, "dynamize does not support associated types of a qualified Self") } diff --git a/src/transform.rs b/src/transform.rs index 74ab9e6..eed48c4 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -26,6 +26,7 @@ pub enum TransformError { UnsupportedType, ExpectedAtLeastNTypes(usize), AssocTypeAfterFirstNTypes(usize, Ident), + QualifiedAssociatedType, QualifiedSelfAssociatedType, } @@ -119,6 +120,9 @@ impl TypeConverter<'_> { { if let Type::Path(self_path) = qself.ty.as_ref() { if self_path.path.segments[0].ident == "Self" { + if !self_path.path.is_ident("Self") { + return Err((self_path.span(), TransformError::QualifiedAssociatedType)); + } return Err(( self_path.span(), TransformError::QualifiedSelfAssociatedType, diff --git a/ui-tests/src/bin/qualified_assoc_type.stderr b/ui-tests/src/bin/qualified_assoc_type.stderr index 4f69ece..0401509 100644 --- a/ui-tests/src/bin/qualified_assoc_type.stderr +++ b/ui-tests/src/bin/qualified_assoc_type.stderr @@ -1,4 +1,4 @@ -error: dynamize does not support associated types of a qualified Self +error: dynamize does not support qualified associated types --> src/bin/qualified_assoc_type.rs:9:24 | 9 | fn test(&self) -> ::B; -- cgit v1.2.3