Add a test for an internally tagged unit enum flattened with a second internally tagged unit enum.
@@ -2269,3 +2269,45 @@ fn test_internally_tagged_unit_enum_with_unknown_fields() {
],
);
}
+
+#[test]
+fn test_flattened_internally_tagged_unit_enum_with_unknown_fields() {
+ #[derive(Deserialize, PartialEq, Debug)]
+ struct S {
+ #[serde(flatten)]
+ x: X,
+ #[serde(flatten)]
+ y: Y,
+ }
+
+ #[derive(Deserialize, PartialEq, Debug)]
+ #[serde(tag = "typeX")]
+ enum X {
+ A,
+ }
+
+ #[derive(Deserialize, PartialEq, Debug)]
+ #[serde(tag = "typeY")]
+ enum Y {
+ B { c: u32 },
+ }
+
+ let s = S {
+ x: X::A,
+ y: Y::B { c: 0 },
+ };
+
+ assert_de_tokens(
+ &s,
+ &[
+ Token::Map { len: None },
+ Token::Str("typeX"),
+ Token::Str("A"),
+ Token::Str("typeY"),
+ Token::Str("B"),
+ Token::Str("c"),
+ Token::I32(0),
+ Token::MapEnd,
+ ],
+ );
+}
