From c59e876bb37ad690090d83e92a7799b75b1a3f49 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 10 Nov 2024 23:23:09 -0800 Subject: [PATCH] Produce a separate warning for every colliding name --- serde_derive/src/de.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 2f18dd8b1..979964cd0 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -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; @@ -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 { @@ -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 @@ -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 @@ -2462,7 +2470,7 @@ fn deserialize_identifier( __E: _serde::de::Error, { match __value { - #(#str_mapping,)* + #(#str_mapping)* _ => { #value_as_str_content #fallthrough_arm @@ -2475,7 +2483,7 @@ fn deserialize_identifier( __E: _serde::de::Error, { match __value { - #(#bytes_mapping,)* + #(#bytes_mapping)* _ => { #bytes_to_str #value_as_bytes_content