aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 67c1223..1a84a09 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -53,9 +53,11 @@ mod syn_utils;
mod transform;
macro_rules! abort {
- ($span:expr, $message:literal) => {
- quote_spanned! {$span => compile_error!($message);}.into()
- };
+ ($span:expr, $message:literal $(,$args:tt)*) => {{
+ let msg = format!($message $(,$args)*);
+ let tokens = quote_spanned! {$span => compile_error!(#msg);}.into();
+ tokens
+ }};
}
#[proc_macro_attribute]
@@ -119,6 +121,21 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
MethodError::Transform(TransformError::UnsupportedType) => {
return abort!(span, "dynamize does not know how to convert this type")
}
+ MethodError::Transform(TransformError::ExpectedAtLeastNTypes(n)) => {
+ return abort!(
+ span,
+ "dynamize expects at least {} generic type arguments for this type",
+ n
+ )
+ }
+ MethodError::Transform(TransformError::AssocTypeAfterFirstNTypes(n, ident)) => {
+ return abort!(
+ span,
+ "for {} dynamize supports associated types only within the first {} generic type parameters",
+ ident,
+ n
+ )
+ }
MethodError::UnconvertedAssocType => {
return abort!(span, "dynamize does not support associated types here")
}