summaryrefslogtreecommitdiffstats
path: root/vendor/serde_derive/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/serde_derive/src
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/serde_derive/src')
-rw-r--r--vendor/serde_derive/src/de.rs18
-rw-r--r--vendor/serde_derive/src/lib.rs2
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 = &params.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 = &params.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