mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1511811 - Update syn and related dependencies. r=emilio
This commit is contained in:
parent
114e1d1f03
commit
e648c4dee9
@ -10,6 +10,6 @@ path = "lib.rs"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "0.5.1"
|
proc-macro2 = "0.4"
|
||||||
syn = { version = "0.13.1", features = ["full"] }
|
syn = { version = "0.15", features = ["full"] }
|
||||||
synstructure = "0.8"
|
synstructure = "0.10"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
//! A crate for deriving the MallocSizeOf trait.
|
//! A crate for deriving the MallocSizeOf trait.
|
||||||
|
|
||||||
extern crate quote;
|
extern crate proc_macro2;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate syn;
|
extern crate syn;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -19,7 +19,7 @@ extern crate synstructure;
|
|||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
decl_derive!([MallocSizeOf, attributes(ignore_malloc_size_of)] => malloc_size_of_derive);
|
decl_derive!([MallocSizeOf, attributes(ignore_malloc_size_of)] => malloc_size_of_derive);
|
||||||
|
|
||||||
fn malloc_size_of_derive(s: synstructure::Structure) -> quote::Tokens {
|
fn malloc_size_of_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
|
||||||
let match_body = s.each(|binding| {
|
let match_body = s.each(|binding| {
|
||||||
let ignore = binding
|
let ignore = binding
|
||||||
.ast()
|
.ast()
|
||||||
@ -61,7 +61,7 @@ fn malloc_size_of_derive(s: synstructure::Structure) -> quote::Tokens {
|
|||||||
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
|
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
|
||||||
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
|
let mut where_clause = where_clause.unwrap_or(&parse_quote!(where)).clone();
|
||||||
for param in ast.generics.type_params() {
|
for param in ast.generics.type_params() {
|
||||||
let ident = param.ident;
|
let ident = ¶m.ident;
|
||||||
where_clause
|
where_clause
|
||||||
.predicates
|
.predicates
|
||||||
.push(parse_quote!(#ident: ::malloc_size_of::MallocSizeOf));
|
.push(parse_quote!(#ident: ::malloc_size_of::MallocSizeOf));
|
||||||
|
@ -10,7 +10,8 @@ path = "lib.rs"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
darling = "0.4"
|
darling = "0.8"
|
||||||
quote = "0.5.1"
|
proc-macro2 = "0.4"
|
||||||
syn = { version = "0.13.1", features = ["visit"] }
|
quote = "0.6"
|
||||||
synstructure = "0.8"
|
syn = { version = "0.15", features = ["visit"] }
|
||||||
|
synstructure = "0.10"
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use darling::util::IdentList;
|
use darling::util::IdentList;
|
||||||
use quote::Tokens;
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::TokenStreamExt;
|
||||||
use syn::{DeriveInput, Path};
|
use syn::{DeriveInput, Path};
|
||||||
use synstructure::{Structure, VariantInfo};
|
use synstructure::{Structure, VariantInfo};
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
@ -67,7 +68,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_variant_arm(variant: &VariantInfo) -> Result<Tokens, ()> {
|
fn derive_variant_arm(variant: &VariantInfo) -> Result<TokenStream, ()> {
|
||||||
let variant_attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast());
|
let variant_attrs = cg::parse_variant_attrs_from_ast::<AnimationVariantAttrs>(&variant.ast());
|
||||||
if variant_attrs.error {
|
if variant_attrs.error {
|
||||||
return Err(());
|
return Err(());
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use darling::{FromDeriveInput, FromField, FromVariant};
|
use darling::{FromDeriveInput, FromField, FromVariant};
|
||||||
use quote::Tokens;
|
use proc_macro2::{Span, TokenStream};
|
||||||
|
use quote::TokenStreamExt;
|
||||||
use syn::{self, AngleBracketedGenericArguments, Binding, DeriveInput, Field};
|
use syn::{self, AngleBracketedGenericArguments, Binding, DeriveInput, Field};
|
||||||
use syn::{GenericArgument, GenericParam, Ident, Path};
|
use syn::{GenericArgument, GenericParam, Ident, Path};
|
||||||
use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray};
|
use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray};
|
||||||
@ -18,9 +19,9 @@ pub fn add_predicate(where_clause: &mut Option<syn::WhereClause>, pred: WherePre
|
|||||||
.push(pred);
|
.push(pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fmap_match<F>(input: &DeriveInput, bind_style: BindStyle, mut f: F) -> Tokens
|
pub fn fmap_match<F>(input: &DeriveInput, bind_style: BindStyle, mut f: F) -> TokenStream
|
||||||
where
|
where
|
||||||
F: FnMut(BindingInfo) -> Tokens,
|
F: FnMut(BindingInfo) -> TokenStream,
|
||||||
{
|
{
|
||||||
let mut s = synstructure::Structure::new(input);
|
let mut s = synstructure::Structure::new(input);
|
||||||
s.variants_mut().iter_mut().for_each(|v| {
|
s.variants_mut().iter_mut().for_each(|v| {
|
||||||
@ -52,7 +53,7 @@ pub fn fmap_trait_output(input: &DeriveInput, trait_path: &Path, trait_output: I
|
|||||||
GenericArgument::Lifetime(data.lifetime.clone())
|
GenericArgument::Lifetime(data.lifetime.clone())
|
||||||
},
|
},
|
||||||
&GenericParam::Type(ref data) => {
|
&GenericParam::Type(ref data) => {
|
||||||
let ident = data.ident;
|
let ident = &data.ident;
|
||||||
GenericArgument::Type(parse_quote!(<#ident as #trait_path>::#trait_output))
|
GenericArgument::Type(parse_quote!(<#ident as #trait_path>::#trait_output))
|
||||||
},
|
},
|
||||||
ref arg => panic!("arguments {:?} cannot be mapped yet", arg),
|
ref arg => panic!("arguments {:?} cannot be mapped yet", arg),
|
||||||
@ -96,7 +97,7 @@ where
|
|||||||
ref path,
|
ref path,
|
||||||
}) => {
|
}) => {
|
||||||
if let Some(ident) = path_to_ident(path) {
|
if let Some(ident) = path_to_ident(path) {
|
||||||
if params.iter().any(|param| param.ident == ident) {
|
if params.iter().any(|ref param| ¶m.ident == ident) {
|
||||||
return f(ident);
|
return f(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +210,7 @@ where
|
|||||||
A: FromVariant,
|
A: FromVariant,
|
||||||
{
|
{
|
||||||
let v = Variant {
|
let v = Variant {
|
||||||
ident: *variant.ident,
|
ident: variant.ident.clone(),
|
||||||
attrs: variant.attrs.to_vec(),
|
attrs: variant.attrs.to_vec(),
|
||||||
fields: variant.fields.clone(),
|
fields: variant.fields.clone(),
|
||||||
discriminant: variant.discriminant.clone(),
|
discriminant: variant.discriminant.clone(),
|
||||||
@ -227,20 +228,23 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ref_pattern<'a>(variant: &'a VariantInfo, prefix: &str) -> (Tokens, Vec<BindingInfo<'a>>) {
|
pub fn ref_pattern<'a>(
|
||||||
|
variant: &'a VariantInfo,
|
||||||
|
prefix: &str,
|
||||||
|
) -> (TokenStream, Vec<BindingInfo<'a>>) {
|
||||||
let mut v = variant.clone();
|
let mut v = variant.clone();
|
||||||
v.bind_with(|_| BindStyle::Ref);
|
v.bind_with(|_| BindStyle::Ref);
|
||||||
v.bindings_mut()
|
v.bindings_mut().iter_mut().for_each(|b| {
|
||||||
.iter_mut()
|
b.binding = Ident::new(&format!("{}_{}", b.binding, prefix), Span::call_site())
|
||||||
.for_each(|b| b.binding = Ident::from(format!("{}_{}", b.binding, prefix)));
|
});
|
||||||
(v.pat(), v.bindings().iter().cloned().collect())
|
(v.pat(), v.bindings().iter().cloned().collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value<'a>(variant: &'a VariantInfo, prefix: &str) -> (Tokens, Vec<BindingInfo<'a>>) {
|
pub fn value<'a>(variant: &'a VariantInfo, prefix: &str) -> (TokenStream, Vec<BindingInfo<'a>>) {
|
||||||
let mut v = variant.clone();
|
let mut v = variant.clone();
|
||||||
v.bindings_mut()
|
v.bindings_mut().iter_mut().for_each(|b| {
|
||||||
.iter_mut()
|
b.binding = Ident::new(&format!("{}_{}", b.binding, prefix), Span::call_site())
|
||||||
.for_each(|b| b.binding = Ident::from(format!("{}_{}", b.binding, prefix)));
|
});
|
||||||
v.bind_with(|_| BindStyle::Move);
|
v.bind_with(|_| BindStyle::Move);
|
||||||
(v.pat(), v.bindings().iter().cloned().collect())
|
(v.pat(), v.bindings().iter().cloned().collect())
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use quote::Tokens;
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::TokenStreamExt;
|
||||||
use syn::{DeriveInput, Path};
|
use syn::{DeriveInput, Path};
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate darling;
|
extern crate darling;
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
extern crate proc_macro2;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use crate::to_css::CssVariantAttrs;
|
use crate::to_css::CssVariantAttrs;
|
||||||
use quote::Tokens;
|
use proc_macro2::TokenStream;
|
||||||
use syn::{DeriveInput, Path};
|
use syn::{DeriveInput, Path};
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ pub struct ParseVariantAttrs {
|
|||||||
pub condition: Option<Path>,
|
pub condition: Option<Path>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn derive(input: DeriveInput) -> Tokens {
|
pub fn derive(input: DeriveInput) -> TokenStream {
|
||||||
let name = &input.ident;
|
let name = &input.ident;
|
||||||
let s = synstructure::Structure::new(&input);
|
let s = synstructure::Structure::new(&input);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
|||||||
let identifier = cg::to_css_identifier(
|
let identifier = cg::to_css_identifier(
|
||||||
&css_variant_attrs
|
&css_variant_attrs
|
||||||
.keyword
|
.keyword
|
||||||
.unwrap_or(variant.ast().ident.as_ref().into()),
|
.unwrap_or(variant.ast().ident.to_string()),
|
||||||
);
|
);
|
||||||
let ident = &variant.ast().ident;
|
let ident = &variant.ast().ident;
|
||||||
|
|
||||||
|
@ -5,16 +5,17 @@
|
|||||||
use crate::cg;
|
use crate::cg;
|
||||||
use crate::parse::ParseVariantAttrs;
|
use crate::parse::ParseVariantAttrs;
|
||||||
use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
|
use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
|
||||||
use quote::Tokens;
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::TokenStreamExt;
|
||||||
use syn::{Data, DeriveInput, Fields, Ident, Type};
|
use syn::{Data, DeriveInput, Fields, Ident, Type};
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input);
|
let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input);
|
||||||
let mut types = vec![];
|
let mut types = vec![];
|
||||||
let mut values = vec![];
|
let mut values = vec![];
|
||||||
|
|
||||||
let input_ident = input.ident;
|
let input_ident = &input.ident;
|
||||||
let input_name = || cg::to_css_identifier(input_ident.as_ref());
|
let input_name = || cg::to_css_identifier(&input_ident.to_string());
|
||||||
if let Some(function) = css_attrs.function {
|
if let Some(function) = css_attrs.function {
|
||||||
values.push(function.explicit().unwrap_or_else(input_name));
|
values.push(function.explicit().unwrap_or_else(input_name));
|
||||||
// If the whole value is wrapped in a function, value types of
|
// If the whole value is wrapped in a function, value types of
|
||||||
@ -49,7 +50,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ident = &v.ident;
|
let ident = &v.ident;
|
||||||
let variant_name = || cg::to_css_identifier(ident.as_ref());
|
let variant_name = || cg::to_css_identifier(&ident.to_string());
|
||||||
if info_attrs.starts_with_keyword {
|
if info_attrs.starts_with_keyword {
|
||||||
values.push(variant_name());
|
values.push(variant_name());
|
||||||
continue;
|
continue;
|
||||||
@ -152,7 +153,7 @@ fn derive_struct_fields<'a>(
|
|||||||
.ident
|
.ident
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("only named field should use represents_keyword");
|
.expect("only named field should use represents_keyword");
|
||||||
values.push(cg::to_css_identifier(ident.as_ref()));
|
values.push(cg::to_css_identifier(&ident.to_string()));
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if let Some(if_empty) = css_attrs.if_empty {
|
if let Some(if_empty) = css_attrs.if_empty {
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use quote;
|
use proc_macro2::{Span, TokenStream};
|
||||||
use syn::DeriveInput;
|
use syn::{DeriveInput, Ident};
|
||||||
use synstructure::BindStyle;
|
use synstructure::BindStyle;
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> quote::Tokens {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
for param in input.generics.type_params() {
|
for param in input.generics.type_params() {
|
||||||
cg::add_predicate(
|
cg::add_predicate(
|
||||||
@ -33,7 +33,7 @@ pub fn derive(mut input: DeriveInput) -> quote::Tokens {
|
|||||||
let animated_value_type = cg::fmap_trait_output(
|
let animated_value_type = cg::fmap_trait_output(
|
||||||
&input,
|
&input,
|
||||||
&parse_quote!(crate::values::animated::ToAnimatedValue),
|
&parse_quote!(crate::values::animated::ToAnimatedValue),
|
||||||
"AnimatedValue".into(),
|
Ident::new("AnimatedValue", Span::call_site()),
|
||||||
);
|
);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use quote;
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::TokenStreamExt;
|
||||||
use syn;
|
use syn;
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
|
||||||
pub fn derive(mut input: syn::DeriveInput) -> quote::Tokens {
|
pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
||||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use quote::Tokens;
|
use proc_macro2::{Span, TokenStream};
|
||||||
use syn::DeriveInput;
|
use syn::{DeriveInput, Ident};
|
||||||
use synstructure::BindStyle;
|
use synstructure::BindStyle;
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
let (to_body, from_body) = {
|
let (to_body, from_body) = {
|
||||||
let params = input.generics.type_params().collect::<Vec<_>>();
|
let params = input.generics.type_params().collect::<Vec<_>>();
|
||||||
@ -79,7 +79,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||||||
let computed_value_type = cg::fmap_trait_output(
|
let computed_value_type = cg::fmap_trait_output(
|
||||||
&input,
|
&input,
|
||||||
&parse_quote!(crate::values::computed::ToComputedValue),
|
&parse_quote!(crate::values::computed::ToComputedValue),
|
||||||
"ComputedValue".into(),
|
Ident::new("ComputedValue", Span::call_site()),
|
||||||
);
|
);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
use crate::cg;
|
use crate::cg;
|
||||||
use darling::util::Override;
|
use darling::util::Override;
|
||||||
use quote::{ToTokens, Tokens};
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::{ToTokens, TokenStreamExt};
|
||||||
use syn::{self, Data, Path, WhereClause};
|
use syn::{self, Data, Path, WhereClause};
|
||||||
use synstructure::{BindingInfo, Structure, VariantInfo};
|
use synstructure::{BindingInfo, Structure, VariantInfo};
|
||||||
|
|
||||||
pub fn derive(mut input: syn::DeriveInput) -> Tokens {
|
pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
for param in input.generics.type_params() {
|
for param in input.generics.type_params() {
|
||||||
cg::add_predicate(&mut where_clause, parse_quote!(#param: style_traits::ToCss));
|
cg::add_predicate(&mut where_clause, parse_quote!(#param: style_traits::ToCss));
|
||||||
@ -66,9 +67,9 @@ pub fn derive(mut input: syn::DeriveInput) -> Tokens {
|
|||||||
impls
|
impls
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_variant_arm(variant: &VariantInfo, generics: &mut Option<WhereClause>) -> Tokens {
|
fn derive_variant_arm(variant: &VariantInfo, generics: &mut Option<WhereClause>) -> TokenStream {
|
||||||
let bindings = variant.bindings();
|
let bindings = variant.bindings();
|
||||||
let identifier = cg::to_css_identifier(variant.ast().ident.as_ref());
|
let identifier = cg::to_css_identifier(&variant.ast().ident.to_string());
|
||||||
let ast = variant.ast();
|
let ast = variant.ast();
|
||||||
let variant_attrs = cg::parse_variant_attrs_from_ast::<CssVariantAttrs>(&ast);
|
let variant_attrs = cg::parse_variant_attrs_from_ast::<CssVariantAttrs>(&ast);
|
||||||
let separator = if variant_attrs.comma { ", " } else { " " };
|
let separator = if variant_attrs.comma { ", " } else { " " };
|
||||||
@ -118,7 +119,7 @@ fn derive_variant_fields_expr(
|
|||||||
bindings: &[BindingInfo],
|
bindings: &[BindingInfo],
|
||||||
where_clause: &mut Option<WhereClause>,
|
where_clause: &mut Option<WhereClause>,
|
||||||
separator: &str,
|
separator: &str,
|
||||||
) -> Tokens {
|
) -> TokenStream {
|
||||||
let mut iter = bindings
|
let mut iter = bindings
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|binding| {
|
.filter_map(|binding| {
|
||||||
@ -166,7 +167,7 @@ fn derive_single_field_expr(
|
|||||||
field: &BindingInfo,
|
field: &BindingInfo,
|
||||||
attrs: CssFieldAttrs,
|
attrs: CssFieldAttrs,
|
||||||
where_clause: &mut Option<WhereClause>,
|
where_clause: &mut Option<WhereClause>,
|
||||||
) -> Tokens {
|
) -> TokenStream {
|
||||||
let mut expr = if attrs.iterable {
|
let mut expr = if attrs.iterable {
|
||||||
if let Some(if_empty) = attrs.if_empty {
|
if let Some(if_empty) = attrs.if_empty {
|
||||||
return quote! {
|
return quote! {
|
||||||
@ -193,7 +194,7 @@ fn derive_single_field_expr(
|
|||||||
.ident
|
.ident
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Unnamed field with represents_keyword?");
|
.expect("Unnamed field with represents_keyword?");
|
||||||
let ident = cg::to_css_identifier(ident.as_ref());
|
let ident = cg::to_css_identifier(&ident.to_string());
|
||||||
quote! {
|
quote! {
|
||||||
if *#field {
|
if *#field {
|
||||||
writer.raw_item(#ident)?;
|
writer.raw_item(#ident)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user