Use parse_macro_input to report parse errors
This commit is contained in:
parent
27bd640812
commit
b49bd52a53
@ -81,7 +81,7 @@ mod try;
|
||||
|
||||
#[proc_macro_derive(Serialize, attributes(serde))]
|
||||
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||
let input: DeriveInput = syn::parse(input).unwrap();
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
ser::expand_derive_serialize(&input)
|
||||
.unwrap_or_else(compile_error)
|
||||
.into()
|
||||
@ -89,7 +89,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||
|
||||
#[proc_macro_derive(Deserialize, attributes(serde))]
|
||||
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
||||
let input: DeriveInput = syn::parse(input).unwrap();
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
de::expand_derive_deserialize(&input)
|
||||
.unwrap_or_else(compile_error)
|
||||
.into()
|
||||
|
Loading…
Reference in New Issue
Block a user