diff options
author | Bastien Orivel <eijebong@bananium.fr> | 2018-02-12 14:29:47 +0100 |
---|---|---|
committer | Bastien Orivel <eijebong@bananium.fr> | 2018-02-12 15:05:18 +0100 |
commit | 0a0d37bea398c7fb0a5c0ee8f2b12af0ff4da169 (patch) | |
tree | 06c908f13d03346ee7862227fe7502c12a5ec096 /components/deny_public_fields | |
parent | 0653f3097c07cac0a44e8a1bb1d431885edd7de0 (diff) | |
download | servo-0a0d37bea398c7fb0a5c0ee8f2b12af0ff4da169.tar.gz servo-0a0d37bea398c7fb0a5c0ee8f2b12af0ff4da169.zip |
Bump syn/quote in deny_public_fields
Diffstat (limited to 'components/deny_public_fields')
-rw-r--r-- | components/deny_public_fields/Cargo.toml | 4 | ||||
-rw-r--r-- | components/deny_public_fields/lib.rs | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/components/deny_public_fields/Cargo.toml b/components/deny_public_fields/Cargo.toml index 6b2c567e29f..45c291aa061 100644 --- a/components/deny_public_fields/Cargo.toml +++ b/components/deny_public_fields/Cargo.toml @@ -10,5 +10,5 @@ path = "lib.rs" proc-macro = true [dependencies] -syn = "0.11" -synstructure = "0.5" +syn = "0.12.12" +synstructure = "0.7" diff --git a/components/deny_public_fields/lib.rs b/components/deny_public_fields/lib.rs index e9b8b7938a2..8d5feb39cbe 100644 --- a/components/deny_public_fields/lib.rs +++ b/components/deny_public_fields/lib.rs @@ -4,24 +4,22 @@ extern crate proc_macro; extern crate syn; +#[macro_use] extern crate synstructure; -#[proc_macro_derive(DenyPublicFields)] -pub fn expand_token_stream(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - expand_string(&input.to_string()).parse().unwrap() -} +use std::str::FromStr; -fn expand_string(input: &str) -> String { - let type_ = syn::parse_macro_input(input).unwrap(); +decl_derive!([DenyPublicFields] => deny_public_fields_derive); - let style = synstructure::BindStyle::Ref.into(); - synstructure::each_field(&type_, &style, |binding| { - if binding.field.vis != syn::Visibility::Inherited { +fn deny_public_fields_derive(s: synstructure::Structure) -> proc_macro::TokenStream { + s.each(|binding| { + if binding.ast().vis != syn::Visibility::Inherited { panic!("Field `{}` should not be public", - binding.field.ident.as_ref().unwrap_or(&binding.ident)); + binding.ast().ident.as_ref().unwrap_or(&binding.binding)); } + "".to_owned() }); - "".to_owned() + proc_macro::TokenStream::from_str("").unwrap() } |