From b908487476633a397685a5a5f5265d4e0a4cd3a4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 12 Oct 2023 19:18:37 -0700 Subject: [PATCH] Remove double nesting of first_attempt `expr` is of type serde_derive::fragment::Expr, which can be interpolated directly in any expression position. It does not need to be nested in another set of braces. --- serde_derive/src/de.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index c6b2cfff2..9942770ae 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -1754,18 +1754,18 @@ fn deserialize_untagged_enum_after( // 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); } } }); + 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);