fix deserialization of untagged variants within internally or adjacently

tagged enums
This commit is contained in:
Adam H. Leventhal
2023-09-07 17:19:27 -07:00
parent 09993a904a
commit 8da2058e2a
2 changed files with 43 additions and 5 deletions
+6 -2
View File
@@ -1749,10 +1749,14 @@ fn deserialize_untagged_enum_after(
);
let fallthrough_msg = cattrs.expecting().unwrap_or(&fallthrough_msg);
// This may be infallible so we need to provide the error type.
// 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 {
if let _serde::__private::Result::<_, __D::Error>::Ok(__ok) = (|| {
#expr
})() {
return _serde::__private::Ok(__ok);
}
}