Auto merge of #354 - dtolnay:attr, r=oli-obk
Fix attributes canceling each other Fixes #353.
This commit is contained in:
commit
bf33daf124
@ -82,7 +82,6 @@ impl ContainerAttrs {
|
||||
// Parse `#[serde(rename="foo")]`
|
||||
ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"rename" => {
|
||||
let s = try!(get_str_from_lit(cx, name, lit));
|
||||
|
||||
container_attrs.name.serialize_name = Some(s.clone());
|
||||
container_attrs.name.deserialize_name = Some(s);
|
||||
}
|
||||
@ -90,9 +89,12 @@ impl ContainerAttrs {
|
||||
// Parse `#[serde(rename(serialize="foo", deserialize="bar"))]`
|
||||
ast::MetaItemKind::List(ref name, ref meta_items) if name == &"rename" => {
|
||||
let (ser_name, de_name) = try!(get_renames(cx, meta_items));
|
||||
|
||||
container_attrs.name.serialize_name = ser_name;
|
||||
container_attrs.name.deserialize_name = de_name;
|
||||
if ser_name.is_some() {
|
||||
container_attrs.name.serialize_name = ser_name;
|
||||
}
|
||||
if de_name.is_some() {
|
||||
container_attrs.name.deserialize_name = de_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse `#[serde(deny_unknown_fields)]`
|
||||
@ -110,8 +112,12 @@ impl ContainerAttrs {
|
||||
// Parse `#[serde(bound(serialize="D: Serialize", deserialize="D: Deserialize"))]`
|
||||
ast::MetaItemKind::List(ref name, ref meta_items) if name == &"bound" => {
|
||||
let (ser_bound, de_bound) = try!(get_where_predicates(cx, meta_items));
|
||||
container_attrs.ser_bound = ser_bound;
|
||||
container_attrs.de_bound = de_bound;
|
||||
if ser_bound.is_some() {
|
||||
container_attrs.ser_bound = ser_bound;
|
||||
}
|
||||
if de_bound.is_some() {
|
||||
container_attrs.de_bound = de_bound;
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
@ -164,7 +170,6 @@ impl VariantAttrs {
|
||||
// Parse `#[serde(rename="foo")]`
|
||||
ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"rename" => {
|
||||
let s = try!(get_str_from_lit(cx, name, lit));
|
||||
|
||||
variant_attrs.name.serialize_name = Some(s.clone());
|
||||
variant_attrs.name.deserialize_name = Some(s);
|
||||
}
|
||||
@ -172,9 +177,12 @@ impl VariantAttrs {
|
||||
// Parse `#[serde(rename(serialize="foo", deserialize="bar"))]`
|
||||
ast::MetaItemKind::List(ref name, ref meta_items) if name == &"rename" => {
|
||||
let (ser_name, de_name) = try!(get_renames(cx, meta_items));
|
||||
|
||||
variant_attrs.name.serialize_name = ser_name;
|
||||
variant_attrs.name.deserialize_name = de_name;
|
||||
if ser_name.is_some() {
|
||||
variant_attrs.name.serialize_name = ser_name;
|
||||
}
|
||||
if de_name.is_some() {
|
||||
variant_attrs.name.deserialize_name = de_name;
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
@ -241,7 +249,6 @@ impl FieldAttrs {
|
||||
// Parse `#[serde(rename="foo")]`
|
||||
ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"rename" => {
|
||||
let s = try!(get_str_from_lit(cx, name, lit));
|
||||
|
||||
field_attrs.name.serialize_name = Some(s.clone());
|
||||
field_attrs.name.deserialize_name = Some(s);
|
||||
}
|
||||
@ -249,9 +256,12 @@ impl FieldAttrs {
|
||||
// Parse `#[serde(rename(serialize="foo", deserialize="bar"))]`
|
||||
ast::MetaItemKind::List(ref name, ref meta_items) if name == &"rename" => {
|
||||
let (ser_name, de_name) = try!(get_renames(cx, meta_items));
|
||||
|
||||
field_attrs.name.serialize_name = ser_name;
|
||||
field_attrs.name.deserialize_name = de_name;
|
||||
if ser_name.is_some() {
|
||||
field_attrs.name.serialize_name = ser_name;
|
||||
}
|
||||
if de_name.is_some() {
|
||||
field_attrs.name.deserialize_name = de_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse `#[serde(default)]`
|
||||
@ -314,8 +324,12 @@ impl FieldAttrs {
|
||||
// Parse `#[serde(bound(serialize="D: Serialize", deserialize="D: Deserialize"))]`
|
||||
ast::MetaItemKind::List(ref name, ref meta_items) if name == &"bound" => {
|
||||
let (ser_bound, de_bound) = try!(get_where_predicates(cx, meta_items));
|
||||
field_attrs.ser_bound = ser_bound;
|
||||
field_attrs.de_bound = de_bound;
|
||||
if ser_bound.is_some() {
|
||||
field_attrs.ser_bound = ser_bound;
|
||||
}
|
||||
if de_bound.is_some() {
|
||||
field_attrs.de_bound = de_bound;
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
@ -441,7 +441,8 @@ enum RenameEnumSerializeDeserialize<A> {
|
||||
#[serde(rename(serialize="dick_grayson", deserialize="jason_todd"))]
|
||||
Robin {
|
||||
a: i8,
|
||||
#[serde(rename(serialize="c", deserialize="d"))]
|
||||
#[serde(rename(serialize="c"))]
|
||||
#[serde(rename(deserialize="d"))]
|
||||
b: A,
|
||||
},
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ struct WithTraits2<D, E> {
|
||||
deserialize_with="DeserializeWith::deserialize_with")]
|
||||
d: D,
|
||||
#[serde(serialize_with="SerializeWith::serialize_with",
|
||||
deserialize_with="DeserializeWith::deserialize_with",
|
||||
bound(serialize="E: SerializeWith",
|
||||
deserialize="E: DeserializeWith"))]
|
||||
bound(serialize="E: SerializeWith"))]
|
||||
#[serde(deserialize_with="DeserializeWith::deserialize_with",
|
||||
bound(deserialize="E: DeserializeWith"))]
|
||||
e: E,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user