Use compile_error! instead of panicking

Fixes #1168
This commit is contained in:
Adam Crume 2018-05-31 19:57:23 -07:00
parent dbaf2893e3
commit 993710eb16

View File

@ -53,6 +53,7 @@ extern crate proc_macro2;
mod internals;
use std::str::FromStr;
use proc_macro::TokenStream;
use syn::DeriveInput;
@ -71,7 +72,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
match ser::expand_derive_serialize(&input) {
Ok(expanded) => expanded.into(),
Err(msg) => panic!(msg),
Err(msg) => TokenStream::from_str(&format!("compile_error!({:?});", msg)).unwrap(),
}
}
@ -80,6 +81,6 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
match de::expand_derive_deserialize(&input) {
Ok(expanded) => expanded.into(),
Err(msg) => panic!(msg),
Err(msg) => TokenStream::from_str(&format!("compile_error!({:?});", msg)).unwrap(),
}
}