Skip to content

Commit

Permalink
Format PR #1917 with rustfmt 1.4.32
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 23, 2021
1 parent ba46f45 commit 60e08f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion serde/src/private/de.rs
@@ -1,7 +1,7 @@
use lib::*;

use de::value::{BorrowedBytesDeserializer, BytesDeserializer};
use de::{Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, Visitor};
use de::value::{BytesDeserializer, BorrowedBytesDeserializer};

#[cfg(any(feature = "std", feature = "alloc"))]
use de::{MapAccess, Unexpected};
Expand Down
39 changes: 15 additions & 24 deletions serde_derive/src/de.rs
Expand Up @@ -1893,23 +1893,20 @@ fn deserialize_generated_identifier(
let fallthrough = quote!(_serde::__private::Ok(__Field::__other(__value)));
(
Some(ignore_variant),
Some((fallthrough.clone(), fallthrough))
Some((fallthrough.clone(), fallthrough)),
)
} else if let Some(other_idx) = other_idx {
let ignore_variant = fields[other_idx].1.clone();
let fallthrough = quote!(_serde::__private::Ok(__Field::#ignore_variant));
(
None,
Some((fallthrough.clone(), fallthrough))
)
(None, Some((fallthrough.clone(), fallthrough)))
} else if is_variant || cattrs.deny_unknown_fields() {
(None, None)
} else {
let ignore_variant = quote!(__ignore,);
let fallthrough = quote!(_serde::__private::Ok(__Field::__ignore));
(
Some(ignore_variant),
Some((fallthrough.clone(), fallthrough))
Some((fallthrough.clone(), fallthrough)),
)
};

Expand Down Expand Up @@ -1973,25 +1970,21 @@ fn deserialize_custom_identifier(
if last.attrs.other() {
let ordinary = &variants[..variants.len() - 1];
let fallthrough = quote!(_serde::__private::Ok(#this::#last_ident));
(
ordinary,
Some((fallthrough.clone(), fallthrough))
)
(ordinary, Some((fallthrough.clone(), fallthrough)))
} else if let Style::Newtype = last.style {
let ordinary = &variants[..variants.len() - 1];
let fallthrough = |method| quote! {
_serde::__private::Result::map(
_serde::Deserialize::deserialize(
_serde::__private::de::IdentifierDeserializer::#method(__value)
),
#this::#last_ident)
let fallthrough = |method| {
quote! {
_serde::__private::Result::map(
_serde::Deserialize::deserialize(
_serde::__private::de::IdentifierDeserializer::#method(__value)
),
#this::#last_ident)
}
};
(
ordinary,
Some((
fallthrough(quote!(from)),
fallthrough(quote!(borrowed)),
))
Some((fallthrough(quote!(from)), fallthrough(quote!(borrowed)))),
)
} else {
(variants, None)
Expand Down Expand Up @@ -2128,10 +2121,8 @@ fn deserialize_identifier(
(None, None, None, None)
};

let (
fallthrough_arm,
fallthrough_borrowed_arm,
) = if let Some(fallthrough) = fallthrough.clone() {
let (fallthrough_arm, fallthrough_borrowed_arm) = if let Some(fallthrough) = fallthrough.clone()
{
fallthrough
} else if is_variant {
let fallthrough = quote! {
Expand Down
11 changes: 2 additions & 9 deletions test_suite/tests/test_borrow.rs
Expand Up @@ -99,12 +99,7 @@ fn test_field_identifier() {
Str(&'a str),
}

assert_de_tokens(
&FieldStr::Str("value"),
&[
Token::BorrowedStr("value"),
],
);
assert_de_tokens(&FieldStr::Str("value"), &[Token::BorrowedStr("value")]);

#[derive(Deserialize, Debug, PartialEq)]
#[serde(field_identifier)]
Expand All @@ -115,9 +110,7 @@ fn test_field_identifier() {

assert_de_tokens(
&FieldBytes::Bytes(b"value"),
&[
Token::BorrowedBytes(b"value"),
],
&[Token::BorrowedBytes(b"value")],
);
}

Expand Down

0 comments on commit 60e08f9

Please sign in to comment.