diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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") } |