diff options
Diffstat (limited to 'vendor/serde_derive/src')
-rw-r--r-- | vendor/serde_derive/src/de.rs | 18 | ||||
-rw-r--r-- | vendor/serde_derive/src/lib.rs | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/vendor/serde_derive/src/de.rs b/vendor/serde_derive/src/de.rs index ee8a23766..e3b737c61 100644 --- a/vendor/serde_derive/src/de.rs +++ b/vendor/serde_derive/src/de.rs @@ -1737,7 +1737,6 @@ fn deserialize_untagged_enum_after( quote!(__deserializer), )) }); - let attempts = first_attempt.into_iter().chain(attempts); // TODO this message could be better by saving the errors from the failed // attempts. The heuristic used by TOML was to count the number of fields // processed before an error, and use the error that happened after the @@ -1750,10 +1749,23 @@ fn deserialize_untagged_enum_after( ); let fallthrough_msg = cattrs.expecting().unwrap_or(&fallthrough_msg); + // Ignore any error associated with non-untagged deserialization so that we + // can fall through to the untagged variants. This may be infallible so we + // need to provide the error type. + let first_attempt = first_attempt.map(|expr| { + quote! { + if let _serde::__private::Result::<_, __D::Error>::Ok(__ok) = (|| #expr)() { + return _serde::__private::Ok(__ok); + } + } + }); + quote_block! { let __content = <_serde::__private::de::Content as _serde::Deserialize>::deserialize(__deserializer)?; let __deserializer = _serde::__private::de::ContentRefDeserializer::<__D::Error>::new(&__content); + #first_attempt + #( if let _serde::__private::Ok(__ok) = #attempts { return _serde::__private::Ok(__ok); @@ -1828,7 +1840,7 @@ fn deserialize_internally_tagged_variant( let this_value = ¶ms.this_value; let type_name = params.type_name(); let variant_name = variant.ident.to_string(); - let default = variant.fields.get(0).map(|field| { + let default = variant.fields.first().map(|field| { let default = Expr(expr_is_missing(field, cattrs)); quote!((#default)) }); @@ -1873,7 +1885,7 @@ fn deserialize_untagged_variant( let this_value = ¶ms.this_value; let type_name = params.type_name(); let variant_name = variant.ident.to_string(); - let default = variant.fields.get(0).map(|field| { + let default = variant.fields.first().map(|field| { let default = Expr(expr_is_missing(field, cattrs)); quote!((#default)) }); diff --git a/vendor/serde_derive/src/lib.rs b/vendor/serde_derive/src/lib.rs index d094242f3..7d653ff0c 100644 --- a/vendor/serde_derive/src/lib.rs +++ b/vendor/serde_derive/src/lib.rs @@ -13,7 +13,7 @@ //! //! [https://serde.rs/derive.html]: https://serde.rs/derive.html -#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.188")] +#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.190")] // Ignored clippy lints #![allow( // clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054 |