Merge pull request #1297 from adamcrume/master

Use compile_error! instead of panicking
This commit is contained in:
David Tolnay
2018-06-02 22:00:24 -07:00
committed by GitHub
63 changed files with 106 additions and 126 deletions
+3 -2
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) => quote! {compile_error!(#msg);}.into(),
}
}
@@ -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) => quote! {compile_error!(#msg);}.into(),
}
}