fix: properly unwrap errors

This commit is contained in:
naskya 2024-07-16 11:16:31 +09:00
parent dc9cc7aaa6
commit 2ca99faef3
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -4,7 +4,10 @@ use syn::{parse_macro_input, spanned::Spanned};
#[proc_macro_derive(Relax, attributes(relax))]
pub fn derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
derive_impl(parse_macro_input!(input)).unwrap().into()
match derive_impl(parse_macro_input!(input)) {
Ok(tokens) => tokens.into(),
Err(error) => error.to_compile_error().into(),
}
}
fn derive_impl(input: syn::DeriveInput) -> syn::Result<TokenStream> {