Update to latest syn and quote
This commit is contained in:
parent
f4e1ffa2cb
commit
b4d5c26f4e
@ -22,8 +22,8 @@ with-syn = []
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "^0.*", optional = true }
|
||||
quote = "0.2"
|
||||
quote = "0.3"
|
||||
serde_codegen_internals = { version = "=0.9.0", default-features = false, path = "../serde_codegen_internals" }
|
||||
syn = { version = "0.8", features = ["aster", "visit"] }
|
||||
syn = { version = "0.9", features = ["aster", "visit"] }
|
||||
syntex = { version = "^0.44.0", optional = true }
|
||||
syntex_syntax = { version = "^0.44.0", optional = true }
|
||||
|
@ -185,17 +185,17 @@ fn deserialize_visitor(generics: &syn::Generics) -> (Tokens, Tokens, Tokens) {
|
||||
let ty_param_idents = if ty_param_idents.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(quote!(::<#(ty_param_idents),*>))
|
||||
Some(quote!(::<#(#ty_param_idents),*>))
|
||||
};
|
||||
|
||||
let phantom_exprs = iter::repeat(quote!(::std::marker::PhantomData)).take(num_phantoms);
|
||||
|
||||
(
|
||||
quote! {
|
||||
struct __Visitor #generics ( #(phantom_types),* ) #where_clause;
|
||||
struct __Visitor #generics ( #(#phantom_types),* ) #where_clause;
|
||||
},
|
||||
quote!(__Visitor <#(all_params),*> ),
|
||||
quote!(__Visitor #ty_param_idents ( #(phantom_exprs),* )),
|
||||
quote!(__Visitor <#(#all_params),*> ),
|
||||
quote!(__Visitor #ty_param_idents ( #(#phantom_exprs),* )),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -358,17 +358,17 @@ fn deserialize_seq(
|
||||
quote!(#ident: #value)
|
||||
});
|
||||
quote! {
|
||||
#type_path { #(args),* }
|
||||
#type_path { #(#args),* }
|
||||
}
|
||||
} else {
|
||||
let args = (0..fields.len()).map(|i| aster::id(format!("__field{}", i)));
|
||||
quote! {
|
||||
#type_path ( #(args),* )
|
||||
#type_path ( #(#args),* )
|
||||
}
|
||||
};
|
||||
|
||||
quote! {
|
||||
#(let_values)*
|
||||
#(#let_values)*
|
||||
|
||||
try!(visitor.end());
|
||||
|
||||
@ -505,7 +505,7 @@ fn deserialize_item_enum(
|
||||
let variant_names = variants.iter().map(|variant| variant.ident.to_string());
|
||||
|
||||
let variants_stmt = quote! {
|
||||
const VARIANTS: &'static [&'static str] = &[ #(variant_names),* ];
|
||||
const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
|
||||
};
|
||||
|
||||
let ignored_arm = if item_attrs.deny_unknown_fields() {
|
||||
@ -551,7 +551,7 @@ fn deserialize_item_enum(
|
||||
where __V: _serde::de::VariantVisitor,
|
||||
{
|
||||
match try!(visitor.visit_variant()) {
|
||||
#(variant_arms)*
|
||||
#(#variant_arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,7 +678,7 @@ fn deserialize_field_visitor(
|
||||
|
||||
let index_body = quote! {
|
||||
match value {
|
||||
#(index_field_arms)*
|
||||
#(#index_field_arms)*
|
||||
_ => #fallthrough_index_arm_expr
|
||||
}
|
||||
};
|
||||
@ -704,7 +704,7 @@ fn deserialize_field_visitor(
|
||||
|
||||
let str_body = quote! {
|
||||
match value {
|
||||
#(str_field_arms)*
|
||||
#(#str_field_arms)*
|
||||
_ => #fallthrough_str_arm_expr
|
||||
}
|
||||
};
|
||||
@ -732,7 +732,7 @@ fn deserialize_field_visitor(
|
||||
|
||||
let bytes_body = quote! {
|
||||
match value {
|
||||
#(bytes_field_arms)*
|
||||
#(#bytes_field_arms)*
|
||||
_ => #fallthrough_bytes_arm_expr
|
||||
}
|
||||
};
|
||||
@ -740,7 +740,7 @@ fn deserialize_field_visitor(
|
||||
quote! {
|
||||
#[allow(non_camel_case_types)]
|
||||
enum __Field {
|
||||
#(field_idents,)*
|
||||
#(#field_idents,)*
|
||||
#ignore_variant
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ fn deserialize_struct_visitor(
|
||||
});
|
||||
|
||||
let fields_stmt = quote! {
|
||||
const FIELDS: &'static [&'static str] = &[ #(field_names),* ];
|
||||
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
||||
};
|
||||
|
||||
(field_visitor, fields_stmt, visit_map)
|
||||
@ -922,21 +922,21 @@ fn deserialize_map(
|
||||
});
|
||||
|
||||
quote! {
|
||||
#(let_values)*
|
||||
#(#let_values)*
|
||||
|
||||
while let Some(key) = try!(visitor.visit_key::<__Field>()) {
|
||||
match key {
|
||||
#(value_arms)*
|
||||
#(skipped_arms)*
|
||||
#(#value_arms)*
|
||||
#(#skipped_arms)*
|
||||
#ignored_arm
|
||||
}
|
||||
}
|
||||
|
||||
try!(visitor.end());
|
||||
|
||||
#(extract_values)*
|
||||
#(#extract_values)*
|
||||
|
||||
Ok(#struct_path { #(result),* })
|
||||
Ok(#struct_path { #(#result),* })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
let mut de = false;
|
||||
let item = syn::MacroInput {
|
||||
attrs: item.attrs.into_iter().flat_map(|attr| {
|
||||
if attr.is_sugared_doc {
|
||||
if attr.is_sugared_doc || attr.style != syn::AttrStyle::Outer {
|
||||
return Some(attr);
|
||||
}
|
||||
let (name, nested) = match attr.value {
|
||||
@ -210,6 +210,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
};
|
||||
if name != "derive" {
|
||||
return Some(syn::Attribute {
|
||||
style: syn::AttrStyle::Outer,
|
||||
value: syn::MetaItem::List(name, nested),
|
||||
is_sugared_doc: false,
|
||||
});
|
||||
@ -231,6 +232,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
None
|
||||
} else {
|
||||
Some(syn::Attribute {
|
||||
style: syn::AttrStyle::Outer,
|
||||
value: syn::MetaItem::List(name, rest),
|
||||
is_sugared_doc: false,
|
||||
})
|
||||
|
@ -168,7 +168,7 @@ fn serialize_tuple_struct(
|
||||
|
||||
quote! {
|
||||
let #let_mut __serde_state = try!(_serializer.serialize_tuple_struct(#type_name, #len));
|
||||
#(serialize_stmts)*
|
||||
#(#serialize_stmts)*
|
||||
_serializer.serialize_tuple_struct_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,7 @@ fn serialize_struct(
|
||||
|
||||
quote! {
|
||||
let #let_mut __serde_state = try!(_serializer.serialize_struct(#type_name, #len));
|
||||
#(serialize_fields)*
|
||||
#(#serialize_fields)*
|
||||
_serializer.serialize_struct_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@ -238,7 +238,7 @@ fn serialize_item_enum(
|
||||
|
||||
quote! {
|
||||
match *self {
|
||||
#(arms)*
|
||||
#(#arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +290,7 @@ fn serialize_variant(
|
||||
})
|
||||
.collect();
|
||||
|
||||
let pat = quote!(#type_ident::#variant_ident(#(field_names),*));
|
||||
let pat = quote!(#type_ident::#variant_ident(#(#field_names),*));
|
||||
|
||||
let block = serialize_tuple_variant(
|
||||
type_name,
|
||||
@ -313,7 +313,7 @@ fn serialize_variant(
|
||||
};
|
||||
quote!(ref #id)
|
||||
});
|
||||
let pat = quote!(#type_ident::#variant_ident { #(fields),* });
|
||||
let pat = quote!(#type_ident::#variant_ident { #(#fields),* });
|
||||
|
||||
let block = serialize_struct_variant(
|
||||
variant_index,
|
||||
@ -381,7 +381,7 @@ fn serialize_tuple_variant(
|
||||
#variant_index,
|
||||
#variant_name,
|
||||
#len));
|
||||
#(serialize_stmts)*
|
||||
#(#serialize_stmts)*
|
||||
_serializer.serialize_tuple_variant_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@ -428,7 +428,7 @@ fn serialize_struct_variant(
|
||||
#variant_name,
|
||||
#len,
|
||||
));
|
||||
#(serialize_fields)*
|
||||
#(#serialize_fields)*
|
||||
_serializer.serialize_struct_variant_end(__serde_state)
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,4 @@ unstable-testing = ["clippy"]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "^0.*", optional = true }
|
||||
syn = "0.8"
|
||||
syn = "0.9"
|
||||
|
Loading…
Reference in New Issue
Block a user