Robustify derive macro attribute parsing (#544)

Missing whitespace in the implementation of `TokenStream::to_string` on
beta and nightly was breaking our parsing of derive macro attributes.

This change makes the parser ignore whitespace, and should make the beta
and nightly builds succeed again.
This commit is contained in:
Michael Sproul
2019-09-28 14:29:14 +10:00
committed by GitHub
parent 2399b9bbe0
commit 3d559d8b41
4 changed files with 16 additions and 28 deletions

View File

@@ -6,12 +6,10 @@ use quote::quote;
use syn::{parse_macro_input, DeriveInput};
fn is_slice(field: &syn::Field) -> bool {
for attr in &field.attrs {
if attr.tts.to_string() == "( as_slice )" {
return true;
}
}
false
field.attrs.iter().any(|attr| {
attr.path.is_ident("compare_fields")
&& attr.tts.to_string().replace(" ", "") == "(as_slice)"
})
}
#[proc_macro_derive(CompareFields, attributes(compare_fields))]