mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Bump syn/quote in deny_public_fields
This commit is contained in:
parent
0653f3097c
commit
0a0d37bea3
4 changed files with 64 additions and 15 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue