diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-02-04 14:14:14 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-02-05 17:54:20 +0100 |
commit | caf3f3ae3d2645dbdc47101e05a88c306a2cb989 (patch) | |
tree | 4cd8b9f9471d1e3ab51992b2fd9a929199f28db8 | |
parent | 46b7c84f0d8fbb7d8659d70477b26d41ce4d4337 (diff) |
ffi-macros: Provide expected type in panics.
-rw-r--r-- | ffi-macros/src/lib.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ffi-macros/src/lib.rs b/ffi-macros/src/lib.rs index e72b610f..131e1f45 100644 --- a/ffi-macros/src/lib.rs +++ b/ffi-macros/src/lib.rs @@ -265,11 +265,13 @@ fn hash_ident(i: &syn::Ident) -> u64 { } /// Derives type and conversion functions. -fn derive_conversion_functions(mut st: syn::ItemStruct, _: &str, _: &str, +fn derive_conversion_functions(mut st: syn::ItemStruct, + prefix: &str, name: &str, wrapped: &syn::Type) -> TokenStream2 { let wrapper = st.ident.clone(); + let c_type_name = format!("{}{}_t", prefix, name); // We now inject a field into the struct definition. This tag // uniquely identifies this wrapper at runtime. @@ -339,7 +341,10 @@ fn derive_conversion_functions(mut st: syn::ItemStruct, _: &str, _: &str, Use after move or use after free detected"); } else { panic!( - "FFI contract violation: Wrong parameter type"); + "FFI contract violation: Wrong parameter type: \ + expected {}", + #c_type_name, + ); } } } |