From 73416da73c943595dc6990c8948a98162a2d2063 Mon Sep 17 00:00:00 2001 From: Soispha Date: Wed, 27 Mar 2024 22:13:57 +0100 Subject: [PATCH] docs(macros/generate): Improve error output --- src/macros/generate/convert/auxiliary/c/type/mod.rs | 4 +++- src/macros/generate/host/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/macros/generate/convert/auxiliary/c/type/mod.rs b/src/macros/generate/convert/auxiliary/c/type/mod.rs index 302b9e7..ecae9e3 100644 --- a/src/macros/generate/convert/auxiliary/c/type/mod.rs +++ b/src/macros/generate/convert/auxiliary/c/type/mod.rs @@ -68,7 +68,9 @@ impl Type { .map(|r#type| r#type.to_auxiliary_c(false, field_name)) .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! { #output (*#field_name) (#(#inputs),*) diff --git a/src/macros/generate/host/mod.rs b/src/macros/generate/host/mod.rs index f514ee1..e416272 100644 --- a/src/macros/generate/host/mod.rs +++ b/src/macros/generate/host/mod.rs @@ -34,7 +34,9 @@ pub mod rust; pub fn format_rust(input: TokenStream2) -> String { 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"), ) }