Merge remote-tracking branch 'remotes/origin/master' into renamed_missing_field

This commit is contained in:
Erick Tryzelaar 2016-04-12 08:24:34 -07:00
commit 1c5d83889c
10 changed files with 92 additions and 84 deletions

View File

@ -689,34 +689,34 @@ how types are serialized. Here are the supported annotations:
Container Annotations: Container Annotations:
| Annotation | Function | | Annotation | Function |
| ---------- | -------- | | ---------- | -------- |
| `#[serde(rename="name")` | Serialize and deserialize this container with the given name | | `#[serde(rename="name")]` | Serialize and deserialize this container with the given name |
| `#[serde(rename(serialize="name1"))` | Serialize this container with the given name | | `#[serde(rename(serialize="name1"))]` | Serialize this container with the given name |
| `#[serde(rename(deserialize="name1"))` | Deserialize this container with the given name | | `#[serde(rename(deserialize="name1"))]` | Deserialize this container with the given name |
| `#[serde(deny_unknown_fields)` | Always error during serialization when encountering unknown fields. When absent, unknown fields are ignored for self-describing formats like JSON. | | `#[serde(deny_unknown_fields)]` | Always error during serialization when encountering unknown fields. When absent, unknown fields are ignored for self-describing formats like JSON. |
Variant Annotations: Variant Annotations:
| Annotation | Function | | Annotation | Function |
| ---------- | -------- | | ---------- | -------- |
| `#[serde(rename="name")` | Serialize and deserialize this variant with the given name | | `#[serde(rename="name")]` | Serialize and deserialize this variant with the given name |
| `#[serde(rename(serialize="name1"))` | Serialize this variant with the given name | | `#[serde(rename(serialize="name1"))]` | Serialize this variant with the given name |
| `#[serde(rename(deserialize="name1"))` | Deserialize this variant with the given name | | `#[serde(rename(deserialize="name1"))]` | Deserialize this variant with the given name |
Field Annotations: Field Annotations:
| Annotation | Function | | Annotation | Function |
| ---------- | -------- | | ---------- | -------- |
| `#[serde(rename="name")` | Serialize and deserialize this field with the given name | | `#[serde(rename="name")]` | Serialize and deserialize this field with the given name |
| `#[serde(rename(serialize="name1"))` | Serialize this field with the given name | | `#[serde(rename(serialize="name1"))]` | Serialize this field with the given name |
| `#[serde(rename(deserialize="name1"))` | Deserialize this field with the given name | | `#[serde(rename(deserialize="name1"))]` | Deserialize this field with the given name |
| `#[serde(default)` | If the value is not specified, use the `Default::default()` | | `#[serde(default)]` | If the value is not specified, use the `Default::default()` |
| `#[serde(default="$path")` | Call the path to a function `fn() -> T` to build the value | | `#[serde(default="$path")]` | Call the path to a function `fn() -> T` to build the value |
| `#[serde(skip_serializing)` | Do not serialize this value | | `#[serde(skip_serializing)]` | Do not serialize this value |
| `#[serde(skip_serializing_if="$path")` | Do not serialize this value if this function `fn(&T) -> bool` returns `false` | | `#[serde(skip_serializing_if="$path")]` | Do not serialize this value if this function `fn(&T) -> bool` returns `false` |
| `#[serde(serialize_with="$path")` | Call a function `fn<T, S>(&T, &mut S) -> Result<(), S::Error> where S: Serializer` to serialize this value | | `#[serde(serialize_with="$path")]` | Call a function `fn<T, S>(&T, &mut S) -> Result<(), S::Error> where S: Serializer` to serialize this value |
| `#[serde(deserialize_with="$path")` | Call a function `fn<T, D>(&mut D) -> Result<T, D::Error> where D: Deserializer` to deserialize this value | | `#[serde(deserialize_with="$path")]` | Call a function `fn<T, D>(&mut D) -> Result<T, D::Error> where D: Deserializer` to deserialize this value |
Upgrading from Serde 0.6 Upgrading from Serde 0.6
======================== ========================

View File

@ -61,7 +61,7 @@ impl<'a> ser::Serialize for Bytes<'a> {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// `ByteBuf` wraps a `Vec<u8>` and serializes as a byte array. /// `ByteBuf` wraps a `Vec<u8>` and serializes as a byte array.
#[derive(Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] #[derive(Clone, Default, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct ByteBuf { pub struct ByteBuf {
bytes: Vec<u8>, bytes: Vec<u8>,
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "serde_codegen" name = "serde_codegen"
version = "0.7.1" version = "0.7.2"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
description = "Macros to auto-generate implementations for the serde framework" description = "Macros to auto-generate implementations for the serde framework"
@ -16,13 +16,13 @@ nightly-testing = ["clippy"]
with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"] with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"]
[build-dependencies] [build-dependencies]
quasi_codegen = { version = "^0.8.0", optional = true } quasi_codegen = { version = "^0.9.0", optional = true }
syntex = { version = "^0.30.0", optional = true } syntex = { version = "^0.31.0", optional = true }
[dependencies] [dependencies]
aster = { version = "^0.14.0", default-features = false } aster = { version = "^0.15.0", default-features = false }
clippy = { version = "^0.*", optional = true } clippy = { version = "^0.*", optional = true }
quasi = { version = "^0.8.0", default-features = false } quasi = { version = "^0.9.0", default-features = false }
quasi_macros = { version = "^0.8.0", optional = true } quasi_macros = { version = "^0.9.0", optional = true }
syntex = { version = "^0.30.0", optional = true } syntex = { version = "^0.31.0", optional = true }
syntex_syntax = { version = "^0.30.0", optional = true } syntex_syntax = { version = "^0.31.0", optional = true }

View File

@ -191,7 +191,7 @@ impl FieldAttrs {
is_enum: bool) -> Result<Self, Error> { is_enum: bool) -> Result<Self, Error> {
let builder = AstBuilder::new(); let builder = AstBuilder::new();
let field_ident = match field.node.ident() { let field_ident = match field.ident {
Some(ident) => ident, Some(ident) => ident,
None => { cx.span_bug(field.span, "struct field has no name?") } None => { cx.span_bug(field.span, "struct field has no name?") }
}; };
@ -205,7 +205,7 @@ impl FieldAttrs {
deserialize_with: None, deserialize_with: None,
}; };
for meta_items in field.node.attrs.iter().filter_map(get_serde_meta_items) { for meta_items in field.attrs.iter().filter_map(get_serde_meta_items) {
for meta_item in meta_items { for meta_item in meta_items {
match meta_item.node { match meta_item.node {
// Parse `#[serde(rename="foo")]` // Parse `#[serde(rename="foo")]`
@ -273,7 +273,7 @@ impl FieldAttrs {
ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"deserialize_with" => { ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"deserialize_with" => {
let expr = wrap_deserialize_with( let expr = wrap_deserialize_with(
cx, cx,
&field.node.ty, &field.ty,
generics, generics,
try!(parse_lit_into_path(cx, name, lit)), try!(parse_lit_into_path(cx, name, lit)),
); );
@ -614,7 +614,7 @@ fn wrap_deserialize_with(cx: &ExtCtxt,
} }
impl $generics ::serde::de::Deserialize for $ty_path $where_clause { impl $generics ::serde::de::Deserialize for $ty_path $where_clause {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: &mut D) -> ::std::result::Result<Self, D::Error>
where D: ::serde::de::Deserializer where D: ::serde::de::Deserializer
{ {
let value = try!($path(deserializer)); let value = try!($path(deserializer));

View File

@ -148,7 +148,7 @@ fn deserialize_item_struct(
) )
} }
ast::VariantData::Tuple(ref fields, _) => { ast::VariantData::Tuple(ref fields, _) => {
if fields.iter().any(|field| !field.node.kind.is_unnamed()) { if fields.iter().any(|field| field.ident.is_some()) {
cx.span_bug(span, "tuple struct has named fields") cx.span_bug(span, "tuple struct has named fields")
} }
@ -163,7 +163,7 @@ fn deserialize_item_struct(
) )
} }
ast::VariantData::Struct(ref fields, _) => { ast::VariantData::Struct(ref fields, _) => {
if fields.iter().any(|field| field.node.kind.is_unnamed()) { if fields.iter().any(|field| field.ident.is_none()) {
cx.span_bug(span, "struct has unnamed fields") cx.span_bug(span, "struct has unnamed fields")
} }
@ -452,9 +452,9 @@ fn deserialize_struct_as_seq(
.enumerate() .enumerate()
.map(|(i, field)| { .map(|(i, field)| {
( (
match field.node.kind { match field.ident {
ast::NamedField(name, _) => name.clone(), Some(name) => name.clone(),
ast::UnnamedField(_) => { None => {
cx.span_bug(field.span, "struct contains unnamed fields") cx.span_bug(field.span, "struct contains unnamed fields")
} }
}, },
@ -583,10 +583,10 @@ fn deserialize_item_enum(
const VARIANTS: &'static [&'static str] = $variants_expr; const VARIANTS: &'static [&'static str] = $variants_expr;
).unwrap(); ).unwrap();
let ignored_arm = if !container_attrs.deny_unknown_fields() { let ignored_arm = if container_attrs.deny_unknown_fields() {
Some(quote_arm!(cx, __Field::__ignore => { Err(::serde::de::Error::end_of_stream()) }))
} else {
None None
} else {
Some(quote_arm!(cx, __Field::__ignore => { Err(::serde::de::Error::end_of_stream()) }))
}; };
// Match arms to extract a variant from a string // Match arms to extract a variant from a string
@ -816,11 +816,11 @@ fn deserialize_field_visitor(
.map(|i| builder.id(format!("__field{}", i))) .map(|i| builder.id(format!("__field{}", i)))
.collect(); .collect();
let ignore_variant = if !container_attrs.deny_unknown_fields() { let ignore_variant = if container_attrs.deny_unknown_fields() {
None
} else {
let skip_ident = builder.id("__ignore"); let skip_ident = builder.id("__ignore");
Some(builder.variant(skip_ident).unit()) Some(builder.variant(skip_ident).unit())
} else {
None
}; };
let field_enum = builder.item() let field_enum = builder.item()
@ -1008,9 +1008,9 @@ fn deserialize_struct_visitor(
.with_exprs( .with_exprs(
fields.iter() fields.iter()
.map(|field| { .map(|field| {
match field.node.kind { match field.ident {
ast::NamedField(name, _) => builder.expr().str(name), Some(name) => builder.expr().str(name),
ast::UnnamedField(_) => { None => {
cx.span_bug(field.span, "struct contains unnamed fields") cx.span_bug(field.span, "struct contains unnamed fields")
} }
} }
@ -1053,12 +1053,12 @@ fn deserialize_map(
// Visit ignored values to consume them // Visit ignored values to consume them
let ignored_arm = if !container_attrs.deny_unknown_fields() { let ignored_arm = if container_attrs.deny_unknown_fields() {
None
} else {
Some(quote_arm!(cx, Some(quote_arm!(cx,
_ => { try!(visitor.visit_value::<::serde::de::impls::IgnoredAny>()); } _ => { try!(visitor.visit_value::<::serde::de::impls::IgnoredAny>()); }
)) ))
} else {
None
}; };
// Match arms to extract a value for a field. // Match arms to extract a value for a field.
@ -1099,9 +1099,9 @@ fn deserialize_map(
.zip(field_names.iter()) .zip(field_names.iter())
.map(|(field, field_name)| { .map(|(field, field_name)| {
( (
match field.node.kind { match field.ident {
ast::NamedField(name, _) => name.clone(), Some(name) => name.clone(),
ast::UnnamedField(_) => { None => {
cx.span_bug(field.span, "struct contains unnamed fields") cx.span_bug(field.span, "struct contains unnamed fields")
} }
}, },

View File

@ -1,5 +1,6 @@
#![cfg_attr(feature = "nightly-testing", plugin(clippy))] #![cfg_attr(feature = "nightly-testing", plugin(clippy))]
#![cfg_attr(feature = "nightly-testing", feature(plugin))] #![cfg_attr(feature = "nightly-testing", feature(plugin))]
#![cfg_attr(feature = "nightly-testing", allow(too_many_arguments))]
#![cfg_attr(feature = "nightly-testing", allow(used_underscore_binding))] #![cfg_attr(feature = "nightly-testing", allow(used_underscore_binding))]
#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin))] #![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin))]
#![cfg_attr(not(feature = "with-syntex"), plugin(quasi_macros))] #![cfg_attr(not(feature = "with-syntex"), plugin(quasi_macros))]

View File

@ -80,7 +80,7 @@ fn serialize_item(
Ok(quote_item!(cx, Ok(quote_item!(cx,
impl $impl_generics ::serde::ser::Serialize for $ty $where_clause { impl $impl_generics ::serde::ser::Serialize for $ty $where_clause {
fn serialize<__S>(&self, serializer: &mut __S) -> ::std::result::Result<(), __S::Error> fn serialize<__S>(&self, _serializer: &mut __S) -> ::std::result::Result<(), __S::Error>
where __S: ::serde::ser::Serializer, where __S: ::serde::ser::Serializer,
{ {
$body $body
@ -151,7 +151,7 @@ fn serialize_item_struct(
) )
} }
ast::VariantData::Tuple(ref fields, _) => { ast::VariantData::Tuple(ref fields, _) => {
if fields.iter().any(|field| !field.node.kind.is_unnamed()) { if fields.iter().any(|field| field.ident.is_some()) {
cx.span_bug(span, "tuple struct has named fields") cx.span_bug(span, "tuple struct has named fields")
} }
@ -165,7 +165,7 @@ fn serialize_item_struct(
) )
} }
ast::VariantData::Struct(ref fields, _) => { ast::VariantData::Struct(ref fields, _) => {
if fields.iter().any(|field| field.node.kind.is_unnamed()) { if fields.iter().any(|field| field.ident.is_none()) {
cx.span_bug(span, "struct has unnamed fields") cx.span_bug(span, "struct has unnamed fields")
} }
@ -188,7 +188,7 @@ fn serialize_unit_struct(
let type_name = container_attrs.name().serialize_name_expr(); let type_name = container_attrs.name().serialize_name_expr();
Ok(quote_expr!(cx, Ok(quote_expr!(cx,
serializer.serialize_unit_struct($type_name) _serializer.serialize_unit_struct($type_name)
)) ))
} }
@ -199,7 +199,7 @@ fn serialize_newtype_struct(
let type_name = container_attrs.name().serialize_name_expr(); let type_name = container_attrs.name().serialize_name_expr();
Ok(quote_expr!(cx, Ok(quote_expr!(cx,
serializer.serialize_newtype_struct($type_name, &self.0) _serializer.serialize_newtype_struct($type_name, &self.0)
)) ))
} }
@ -229,7 +229,7 @@ fn serialize_tuple_struct(
Ok(quote_expr!(cx, { Ok(quote_expr!(cx, {
$visitor_struct $visitor_struct
$visitor_impl $visitor_impl
serializer.serialize_tuple_struct($type_name, Visitor { _serializer.serialize_tuple_struct($type_name, Visitor {
value: self, value: self,
state: 0, state: 0,
_structure_ty: ::std::marker::PhantomData::<&$ty>, _structure_ty: ::std::marker::PhantomData::<&$ty>,
@ -264,7 +264,7 @@ fn serialize_struct(
Ok(quote_expr!(cx, { Ok(quote_expr!(cx, {
$visitor_struct $visitor_struct
$visitor_impl $visitor_impl
serializer.serialize_struct($type_name, Visitor { _serializer.serialize_struct($type_name, Visitor {
value: self, value: self,
state: 0, state: 0,
_structure_ty: ::std::marker::PhantomData::<&$ty>, _structure_ty: ::std::marker::PhantomData::<&$ty>,
@ -331,7 +331,7 @@ fn serialize_variant(
Ok(quote_arm!(cx, Ok(quote_arm!(cx,
$pat => { $pat => {
::serde::ser::Serializer::serialize_unit_variant( ::serde::ser::Serializer::serialize_unit_variant(
serializer, _serializer,
$type_name, $type_name,
$variant_index, $variant_index,
$variant_name, $variant_name,
@ -350,7 +350,7 @@ fn serialize_variant(
Ok(quote_arm!(cx, Ok(quote_arm!(cx,
$pat => { $pat => {
::serde::ser::Serializer::serialize_newtype_variant( ::serde::ser::Serializer::serialize_newtype_variant(
serializer, _serializer,
$type_name, $type_name,
$variant_index, $variant_index,
$variant_name, $variant_name,
@ -399,9 +399,9 @@ fn serialize_variant(
field_names.iter() field_names.iter()
.zip(fields.iter()) .zip(fields.iter())
.map(|(id, field)| { .map(|(id, field)| {
let name = match field.node.kind { let name = match field.ident {
ast::NamedField(name, _) => name, Some(name) => name,
ast::UnnamedField(_) => { None => {
cx.span_bug(field.span, "struct variant has unnamed fields") cx.span_bug(field.span, "struct variant has unnamed fields")
} }
}; };
@ -447,7 +447,7 @@ fn serialize_tuple_variant(
builder.ty() builder.ty()
.ref_() .ref_()
.lifetime("'__a") .lifetime("'__a")
.build_ty(field.node.ty.clone()) .build_ty(field.ty.clone())
}) })
) )
.build(); .build();
@ -473,7 +473,7 @@ fn serialize_tuple_variant(
quote_expr!(cx, { quote_expr!(cx, {
$visitor_struct $visitor_struct
$visitor_impl $visitor_impl
serializer.serialize_tuple_variant($type_name, $variant_index, $variant_name, Visitor { _serializer.serialize_tuple_variant($type_name, $variant_index, $variant_name, Visitor {
value: $value_expr, value: $value_expr,
state: 0, state: 0,
_structure_ty: ::std::marker::PhantomData::<&$structure_ty>, _structure_ty: ::std::marker::PhantomData::<&$structure_ty>,
@ -502,12 +502,12 @@ fn serialize_struct_variant(
.with_generics(variant_generics.clone()) .with_generics(variant_generics.clone())
.with_fields( .with_fields(
fields.iter().map(|field| { fields.iter().map(|field| {
builder.struct_field(field.node.ident().expect("struct has unnamed fields")) builder.struct_field(field.ident.expect("struct has unnamed fields"))
.with_attrs(field.node.attrs.iter().cloned()) .with_attrs(field.attrs.iter().cloned())
.ty() .ty()
.ref_() .ref_()
.lifetime("'__serde_variant") .lifetime("'__serde_variant")
.build_ty(field.node.ty.clone()) .build_ty(field.ty.clone())
}) })
) )
.field("__serde_container_ty") .field("__serde_container_ty")
@ -520,7 +520,7 @@ fn serialize_struct_variant(
.zip(field_names.iter()) .zip(field_names.iter())
.map(|(field, field_name)| { .map(|(field, field_name)| {
( (
field.node.ident().expect("struct has unnamed fields"), field.ident.expect("struct has unnamed fields"),
builder.expr().id(field_name), builder.expr().id(field_name),
) )
}) })
@ -557,7 +557,7 @@ fn serialize_struct_variant(
$variant_struct $variant_struct
$visitor_struct $visitor_struct
$visitor_impl $visitor_impl
serializer.serialize_struct_variant( _serializer.serialize_struct_variant(
$container_name, $container_name,
$variant_index, $variant_index,
$variant_name, $variant_name,
@ -582,7 +582,7 @@ fn serialize_tuple_struct_visitor(
let arms: Vec<ast::Arm> = (0 .. fields) let arms: Vec<ast::Arm> = (0 .. fields)
.map(|i| { .map(|i| {
let expr = builder.expr().method_call(serializer_method) let expr = builder.expr().method_call(serializer_method)
.id("serializer") .id("_serializer")
.arg().ref_().tup_field(i).field("value").self_() .arg().ref_().tup_field(i).field("value").self_()
.build(); .build();
@ -620,7 +620,7 @@ fn serialize_tuple_struct_visitor(
for Visitor $visitor_generics for Visitor $visitor_generics
$where_clause { $where_clause {
#[inline] #[inline]
fn visit<S>(&mut self, serializer: &mut S) -> ::std::result::Result<Option<()>, S::Error> fn visit<S>(&mut self, _serializer: &mut S) -> ::std::result::Result<Option<()>, S::Error>
where S: ::serde::ser::Serializer where S: ::serde::ser::Serializer
{ {
match self.state { match self.state {
@ -656,7 +656,7 @@ fn serialize_struct_visitor(
.filter(|&(_, ref field_attr)| !field_attr.skip_serializing_field()) .filter(|&(_, ref field_attr)| !field_attr.skip_serializing_field())
.enumerate() .enumerate()
.map(|(i, (ref field, ref field_attr))| { .map(|(i, (ref field, ref field_attr))| {
let name = field.node.ident().expect("struct has unnamed field"); let name = field.ident.expect("struct has unnamed field");
let key_expr = field_attr.name().serialize_name_expr(); let key_expr = field_attr.name().serialize_name_expr();
@ -672,7 +672,7 @@ fn serialize_struct_visitor(
}; };
let expr = quote_expr!(cx, let expr = quote_expr!(cx,
serializer.$serializer_method($key_expr, $field_expr) _serializer.$serializer_method($key_expr, $field_expr)
); );
quote_arm!(cx, quote_arm!(cx,
@ -725,7 +725,7 @@ fn serialize_struct_visitor(
for Visitor $visitor_generics for Visitor $visitor_generics
$where_clause { $where_clause {
#[inline] #[inline]
fn visit<S>(&mut self, serializer: &mut S) -> ::std::result::Result<Option<()>, S::Error> fn visit<S>(&mut self, _serializer: &mut S) -> ::std::result::Result<Option<()>, S::Error>
where S: ::serde::ser::Serializer, where S: ::serde::ser::Serializer,
{ {
loop { loop {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "serde_macros" name = "serde_macros"
version = "0.7.0" version = "0.7.2"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
description = "Macros to auto-generate implementations for the serde framework" description = "Macros to auto-generate implementations for the serde framework"
@ -17,7 +17,7 @@ nightly-testing = ["clippy", "serde/nightly-testing", "serde_codegen/nightly-tes
[dependencies] [dependencies]
clippy = { version = "^0.*", optional = true } clippy = { version = "^0.*", optional = true }
serde_codegen = { version = "^0.7.0", path = "../serde_codegen", default-features = false, features = ["nightly"] } serde_codegen = { version = "^0.7.2", path = "../serde_codegen", default-features = false, features = ["nightly"] }
[dev-dependencies] [dev-dependencies]
compiletest_rs = "^0.1.1" compiletest_rs = "^0.1.1"

View File

@ -14,14 +14,14 @@ build = "build.rs"
nightly-testing = ["clippy", "serde/nightly-testing", "serde_codegen/nightly-testing"] nightly-testing = ["clippy", "serde/nightly-testing", "serde_codegen/nightly-testing"]
[build-dependencies] [build-dependencies]
syntex = { version = "^0.30.0" } syntex = { version = "^0.31.0" }
syntex_syntax = { version = "^0.30.0" } syntex_syntax = { version = "^0.31.0" }
serde_codegen = { version = "*", path = "../serde_codegen", features = ["with-syntex"] } serde_codegen = { version = "*", path = "../serde_codegen", features = ["with-syntex"] }
[dev-dependencies] [dev-dependencies]
rustc-serialize = "^0.3.16" rustc-serialize = "^0.3.16"
serde = { version = "*", path = "../serde" } serde = { version = "*", path = "../serde" }
syntex = "^0.30.0" syntex = "^0.31.0"
[dependencies] [dependencies]
clippy = { version = "^0.*", optional = true } clippy = { version = "^0.*", optional = true }

View File

@ -6,6 +6,13 @@ trait Trait {
} }
*/ */
// That tests that the derived Serialize implementation doesn't trigger
// any warning about `serializer` not being used, in case of empty enums.
#[derive(Serialize)]
#[allow(dead_code)]
#[deny(unused_variables)]
enum Void {}
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
struct NamedUnit; struct NamedUnit;