mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update syn and related dependencies
This commit is contained in:
parent
e4c80d0a88
commit
e94de4e1bd
22 changed files with 215 additions and 226 deletions
|
@ -10,13 +10,16 @@ extern crate quote;
|
|||
#[macro_use]
|
||||
extern crate syn;
|
||||
|
||||
use proc_macro2;
|
||||
use quote::TokenStreamExt;
|
||||
|
||||
#[proc_macro_derive(DomObject)]
|
||||
pub fn expand_token_stream(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = syn::parse(input).unwrap();
|
||||
expand_dom_object(input).into()
|
||||
}
|
||||
|
||||
fn expand_dom_object(input: syn::DeriveInput) -> quote::Tokens {
|
||||
fn expand_dom_object(input: syn::DeriveInput) -> proc_macro2::TokenStream {
|
||||
let fields = if let syn::Data::Struct(syn::DataStruct { ref fields, .. }) = input.data {
|
||||
fields.iter().collect::<Vec<&syn::Field>>()
|
||||
} else {
|
||||
|
@ -62,8 +65,8 @@ fn expand_dom_object(input: syn::DeriveInput) -> quote::Tokens {
|
|||
}
|
||||
};
|
||||
|
||||
let mut params = quote::Tokens::new();
|
||||
params.append_separated(input.generics.type_params().map(|param| param.ident), ", ");
|
||||
let mut params = proc_macro2::TokenStream::new();
|
||||
params.append_separated(input.generics.type_params().map(|param| ¶m.ident), ", ");
|
||||
|
||||
// For each field in the struct, we implement ShouldNotImplDomObject for a
|
||||
// pair of all the type parameters of the DomObject and and the field type.
|
||||
|
@ -87,7 +90,10 @@ fn expand_dom_object(input: syn::DeriveInput) -> quote::Tokens {
|
|||
impl #impl_generics ShouldNotImplDomObject for ((#params), __T) #where_clause {}
|
||||
});
|
||||
|
||||
let dummy_const = syn::Ident::from(format!("_IMPL_DOMOBJECT_FOR_{}", name));
|
||||
let dummy_const = syn::Ident::new(
|
||||
&format!("_IMPL_DOMOBJECT_FOR_{}", name),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let tokens = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
const #dummy_const: () = { #items };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue