Skip to content

Commit

Permalink
Produce a separate warning for every colliding name
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 11, 2024
1 parent 7f1e697 commit c59e876
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,11 @@ fn deserialize_identifier(
let ident = &field.ident;
let aliases = field.aliases;
// `aliases` also contains a main name
quote!(#(#aliases)|* => _serde::__private::Ok(#this_value::#ident))
quote! {
#(
#aliases => _serde::__private::Ok(#this_value::#ident),
)*
}
});
let bytes_mapping = deserialized_fields.iter().map(|field| {
let ident = &field.ident;
Expand All @@ -2226,7 +2230,11 @@ fn deserialize_identifier(
.aliases
.iter()
.map(|alias| Literal::byte_string(alias.value.as_bytes()));
quote!(#(#aliases)|* => _serde::__private::Ok(#this_value::#ident))
quote! {
#(
#aliases => _serde::__private::Ok(#this_value::#ident),
)*
}
});

let expecting = expecting.unwrap_or(if is_variant {
Expand Down Expand Up @@ -2424,7 +2432,7 @@ fn deserialize_identifier(
__E: _serde::de::Error,
{
match __value {
#(#str_mapping,)*
#(#str_mapping)*
_ => {
#value_as_borrowed_str_content
#fallthrough_borrowed_arm
Expand All @@ -2437,7 +2445,7 @@ fn deserialize_identifier(
__E: _serde::de::Error,
{
match __value {
#(#bytes_mapping,)*
#(#bytes_mapping)*
_ => {
#bytes_to_str
#value_as_borrowed_bytes_content
Expand All @@ -2462,7 +2470,7 @@ fn deserialize_identifier(
__E: _serde::de::Error,
{
match __value {
#(#str_mapping,)*
#(#str_mapping)*
_ => {
#value_as_str_content
#fallthrough_arm
Expand All @@ -2475,7 +2483,7 @@ fn deserialize_identifier(
__E: _serde::de::Error,
{
match __value {
#(#bytes_mapping,)*
#(#bytes_mapping)*
_ => {
#bytes_to_str
#value_as_bytes_content
Expand Down

0 comments on commit c59e876

Please sign in to comment.