diff --git a/serde_derive/src/internals/check.rs b/serde_derive/src/internals/check.rs index 0e2484a79..5fb11b824 100644 --- a/serde_derive/src/internals/check.rs +++ b/serde_derive/src/internals/check.rs @@ -267,8 +267,10 @@ fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) { match variant.style { Style::Struct => { for field in &variant.fields { - let check_ser = !field.attrs.skip_serializing(); - let check_de = !field.attrs.skip_deserializing(); + let check_ser = + !(field.attrs.skip_serializing() || variant.attrs.skip_serializing()); + let check_de = + !(field.attrs.skip_deserializing() || variant.attrs.skip_deserializing()); let name = field.attrs.name(); let ser_name = name.serialize_name(); diff --git a/test_suite/tests/test_annotations.rs b/test_suite/tests/test_annotations.rs index f4939d979..2fd05fb43 100644 --- a/test_suite/tests/test_annotations.rs +++ b/test_suite/tests/test_annotations.rs @@ -2265,6 +2265,37 @@ fn test_externally_tagged_enum_containing_flatten() { ); } +#[test] +fn test_internally_tagged_enum_with_skipped_conflict() { + #[derive(Serialize, Deserialize, PartialEq, Debug)] + #[serde(tag = "t")] + enum Data { + A, + #[serde(skip)] + B { + t: String + }, + C { + #[serde(default, skip)] + t: String + }, + } + + let _data = Data::B { t: "".to_string() }; + + let data = Data::C { t: "".to_string() }; + + assert_tokens( + &data, + &[ + Token::Struct { name: "Data", len: 1 }, + Token::Str("t"), + Token::Str("C"), + Token::StructEnd, + ], + ); +} + #[test] fn test_internally_tagged_enum_containing_flatten() { #[derive(Serialize, Deserialize, PartialEq, Debug)]