Fix SignedRoot macro attribute parsing

This commit is contained in:
Michael Sproul 2019-09-30 12:32:44 +10:00
parent 81325a0e05
commit 01db3b6f4e
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914

View File

@ -2,7 +2,7 @@
extern crate proc_macro; extern crate proc_macro;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use quote::{quote, ToTokens}; use quote::quote;
use syn::{parse_macro_input, DeriveInput}; use syn::{parse_macro_input, DeriveInput};
/// Returns a Vec of `syn::Ident` for each named field in the struct, whilst filtering out fields /// Returns a Vec of `syn::Ident` for each named field in the struct, whilst filtering out fields
@ -130,8 +130,8 @@ fn get_signed_root_named_field_idents(struct_data: &syn::DataStruct) -> Vec<&syn
} }
fn should_skip_signed_root(field: &syn::Field) -> bool { fn should_skip_signed_root(field: &syn::Field) -> bool {
field field.attrs.iter().any(|attr| {
.attrs attr.path.is_ident("signed_root")
.iter() && attr.tts.to_string().replace(" ", "") == "(skip_hashing)"
.any(|attr| attr.into_token_stream().to_string() == "# [ signed_root ( skip_hashing ) ]") })
} }