Skip to content

Commit

Permalink
Do not run the code when results are not used
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Jul 23, 2023
1 parent 089aae1 commit f709fc0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,21 +2281,6 @@ fn deserialize_identifier(
&fallthrough_arm_tokens
};

let u64_fallthrough_arm_tokens;
let u64_fallthrough_arm = if let Some(fallthrough) = &fallthrough {
fallthrough
} else {
let index_expecting = if is_variant { "variant" } else { "field" };
let fallthrough_msg = format!("{} index 0 <= i < {}", index_expecting, fields.len());
u64_fallthrough_arm_tokens = quote! {
_serde::__private::Err(_serde::de::Error::invalid_value(
_serde::de::Unexpected::Unsigned(__value),
&#fallthrough_msg,
))
};
&u64_fallthrough_arm_tokens
};

let visit_other = if collect_other_fields {
quote! {
fn visit_bool<__E>(self, __value: bool) -> _serde::__private::Result<Self::Value, __E>
Expand Down Expand Up @@ -2395,6 +2380,21 @@ fn deserialize_identifier(
quote!(#i => _serde::__private::Ok(#this_value::#ident))
});

let u64_fallthrough_arm_tokens;
let u64_fallthrough_arm = if let Some(fallthrough) = &fallthrough {
fallthrough
} else {
let index_expecting = if is_variant { "variant" } else { "field" };
let fallthrough_msg = format!("{} index 0 <= i < {}", index_expecting, fields.len());
u64_fallthrough_arm_tokens = quote! {
_serde::__private::Err(_serde::de::Error::invalid_value(
_serde::de::Unexpected::Unsigned(__value),
&#fallthrough_msg,
))
};
&u64_fallthrough_arm_tokens
};

quote! {
fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result<Self::Value, __E>
where
Expand Down

0 comments on commit f709fc0

Please sign in to comment.