diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-22 12:57:53 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-22 13:03:47 +0100 |
commit | 684d7e5873aa0b6423e167124fd8c72e02173ba2 (patch) | |
tree | e53af9b8b4abcd815cfdac5871d145ef73ac4d39 /src/lib.rs | |
parent | 890247746e74e015acbb290c925284c5047a580c (diff) |
better errors for type arguments of collections
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") } |