docs(macros/generate): Improve error output

This commit is contained in:
Benedikt Peetz 2024-03-27 22:13:57 +01:00
parent febb2deae3
commit 73416da73c
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
2 changed files with 6 additions and 2 deletions

View File

@ -68,7 +68,9 @@ impl Type {
.map(|r#type| r#type.to_auxiliary_c(false, field_name)) .map(|r#type| r#type.to_auxiliary_c(false, field_name))
.collect(); .collect();
let field_name = field_name.expect("This is some, when I'm a function type").to_rust(); let field_name = field_name
.expect("This is some, when it's a function type")
.to_rust();
quote! { quote! {
#output (*#field_name) (#(#inputs),*) #output (*#field_name) (#(#inputs),*)

View File

@ -34,7 +34,9 @@ pub mod rust;
pub fn format_rust(input: TokenStream2) -> String { pub fn format_rust(input: TokenStream2) -> String {
prettyplease::unparse( prettyplease::unparse(
&syn::parse2(input).expect("This code was generated, it should also be parsable"), &syn::parse2(input.clone()).map_err(|err| {
eprintln!("{}:\n===\n{}\n===\n", err, input);
}).expect("This code was generated, it should also be parsable"),
) )
} }