Repository: tafia/quick-xml
Pull request #821 (2024-10-12 11:57:28)

Because serde issues #1904 and #2371 are fixed, remove workarounds for them from tests
Related issues:
- https://github.com/serde-rs/serde/issues/1904
- https://github.com/serde-rs/serde/issues/2371


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index d512c9e..fcd6494 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,9 +30,9 @@ arbitrary = { version = "1", features = ["derive"], optional = true }
 criterion = "0.4"
 pretty_assertions = "1.4"
 regex = "1"
-# #[serde(other)] allowed not only inside field_identifier since 1.0.79
+# https://github.com/serde-rs/serde/issues/1904 is fixed since 1.0.206
 # serde does not follow semver in numbering and their dependencies, so we specifying patch here
-serde_derive = { version = "1.0.79" }
+serde_derive = { version = "1.0.206" }
 serde-value = "0.7"
 tokio = { version = "1.21", default-features = false, features = ["macros", "rt"] }
 tokio-test = "0.4"


Test patch:
diff --git a/tests/serde-se.rs b/tests/serde-se.rs
index 3c4f7d1..fc56062 100644
--- a/tests/serde-se.rs
+++ b/tests/serde-se.rs
@@ -67,6 +67,11 @@ enum ExternallyTagged {
         nested: Nested,
         string: &'static str,
     },
+    Flatten {
+        #[serde(flatten)]
+        nested: Nested,
+        string: &'static str,
+    },
     /// `float` field serialized as textual content instead of a tag
     Text {
         #[serde(rename = "$text")]
@@ -80,22 +85,6 @@ enum ExternallyTagged {
     },
 }
 
-/// Having both `#[serde(flatten)]` and `'static` fields in one struct leads to
-/// incorrect code generation when deriving `Deserialize`.
-///
-/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/2371>
-///
-/// Anyway, deserialization of that type in roundtrip suffers from
-/// <https://github.com/serde-rs/serde/issues/1183>
-#[derive(Debug, PartialEq, Deserialize, Serialize)]
-enum ExternallyTaggedWorkaround {
-    Flatten {
-        #[serde(flatten)]
-        nested: Nested,
-        string: &'static str,
-    },
-}
-
 #[derive(Debug, PartialEq, Deserialize, Serialize)]
 #[serde(tag = "tag")]
 enum InternallyTagged {
@@ -111,6 +100,11 @@ enum InternallyTagged {
         nested: Nested,
         string: &'static str,
     },
+    Flatten {
+        #[serde(flatten)]
+        nested: Nested,
+        string: &'static str,
+    },
     /// `float` field serialized as textual content instead of a tag
     Text {
         #[serde(rename = "$text")]
@@ -124,23 +118,6 @@ enum InternallyTagged {
     },
 }
 
-/// Having both `#[serde(flatten)]` and `'static` fields in one struct leads to
-/// incorrect code generation when deriving `Deserialize`.
-///
-/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/2371>
-///
-/// Anyway, deserialization of that type in roundtrip suffers from
-/// <https://github.com/serde-rs/serde/issues/1183>
-#[derive(Debug, PartialEq, Serialize)]
-#[serde(tag = "tag")]
-enum InternallyTaggedWorkaround {
-    Flatten {
-        #[serde(flatten)]
-        nested: Nested,
-        string: &'static str,
-    },
-}
-
 #[derive(Debug, PartialEq, Deserialize, Serialize)]
 #[serde(tag = "tag", content = "content")]
 enum AdjacentlyTagged {
@@ -155,6 +132,11 @@ enum AdjacentlyTagged {
         nested: Nested,
         string: &'static str,
     },
+    Flatten {
+        #[serde(flatten)]
+        nested: Nested,
+        string: &'static str,
+    },
     /// `float` field serialized as textual content instead of a tag
     Text {
         #[serde(rename = "$text")]
@@ -168,23 +150,6 @@ enum AdjacentlyTagged {
     },
 }
 
-/// Having both `#[serde(flatten)]` and `'static` fields in one struct leads to
-/// incorrect code generation when deriving `Deserialize`.
-///
-/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/2371>
-///
-/// Anyway, deserialization of that type in roundtrip suffers from
-/// <https://github.com/serde-rs/serde/issues/1183>
-#[derive(Serialize)]
-#[serde(tag = "tag", content = "content")]
-enum AdjacentlyTaggedWorkaround {
-    Flatten {
-        #[serde(flatten)]
-        nested: Nested,
-        string: &'static str,
-    },
-}
-
 #[derive(Debug, PartialEq, Deserialize, Serialize)]
 #[serde(untagged)]
 enum Untagged {
@@ -199,6 +164,11 @@ enum Untagged {
         nested: Nested,
         string: &'static str,
     },
+    Flatten {
+        #[serde(flatten)]
+        nested: Nested,
+        string: &'static str,
+    },
     /// `float` field serialized as textual content instead of a tag
     Text {
         #[serde(rename = "$text")]
@@ -212,23 +182,6 @@ enum Untagged {
     },
 }
 
-/// Having both `#[serde(flatten)]` and `'static` fields in one struct leads to
-/// incorrect code generation when deriving `Deserialize`.
-///
-/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/2371>
-///
-/// Anyway, deserialization of that type in roundtrip suffers from
-/// <https://github.com/serde-rs/serde/issues/1183>
-#[derive(Serialize)]
-#[serde(untagged)]
-enum UntaggedWorkaround {
-    Flatten {
-        #[serde(flatten)]
-        nested: Nested,
-        string: &'static str,
-    },
-}
-
 mod without_root {
     use super::*;
     use pretty_assertions::assert_eq;
@@ -443,7 +396,7 @@ mod without_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                ExternallyTaggedWorkaround::Flatten {
+                ExternallyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -822,7 +775,7 @@ mod without_root {
                 // NOTE: Cannot be deserialized in roundtrip due to
                 // https://github.com/serde-rs/serde/issues/1183
                 serialize_as_only!(flatten_struct:
-                    Root { field: ExternallyTaggedWorkaround::Flatten {
+                    Root { field: ExternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }}
@@ -914,7 +867,7 @@ mod without_root {
                 // NOTE: Cannot be deserialized in roundtrip due to
                 // https://github.com/serde-rs/serde/issues/1183
                 serialize_as_only!(flatten_struct:
-                    Root { field: Inner { inner: ExternallyTaggedWorkaround::Flatten {
+                    Root { field: Inner { inner: ExternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }}}
@@ -996,12 +949,12 @@ mod without_root {
                     => Unsupported("cannot serialize enum struct variant `ExternallyTagged::Holder` as text content value"),
                     "<Root");
                 err!(flatten_struct:
-                    Root { field: ExternallyTaggedWorkaround::Flatten {
+                    Root { field: ExternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }}
                     // Flatten enum struct variants represented as newtype variants containing maps
-                    => Unsupported("cannot serialize enum newtype variant `ExternallyTaggedWorkaround::Flatten` as text content value"),
+                    => Unsupported("cannot serialize enum newtype variant `ExternallyTagged::Flatten` as text content value"),
                     "<Root");
                 err!(empty_struct:
                     Root { field: ExternallyTagged::Empty {} }
@@ -1055,12 +1008,12 @@ mod without_root {
                     => Unsupported("cannot serialize enum struct variant `ExternallyTagged::Holder` as text content value"),
                     "<Root");
                 err!(flatten_struct:
-                    Root { field: Inner { inner: ExternallyTaggedWorkaround::Flatten {
+                    Root { field: Inner { inner: ExternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }}}
                     // Flatten enum struct variants represented as newtype variants containing maps
-                    => Unsupported("cannot serialize enum newtype variant `ExternallyTaggedWorkaround::Flatten` as text content value"),
+                    => Unsupported("cannot serialize enum newtype variant `ExternallyTagged::Flatten` as text content value"),
                     "<Root");
                 err!(empty_struct:
                     Root { field: Inner { inner: ExternallyTagged::Empty {} } }
@@ -1125,7 +1078,7 @@ mod without_root {
             // serde serializes flatten structs as maps, and we do not support
             // serialization of maps without root tag
             err!(flatten_struct:
-                InternallyTaggedWorkaround::Flatten {
+                InternallyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -1201,17 +1154,17 @@ mod without_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                AdjacentlyTaggedWorkaround::Flatten {
+                AdjacentlyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
-                => "<AdjacentlyTaggedWorkaround>\
+                => "<AdjacentlyTagged>\
                         <tag>Flatten</tag>\
                         <content>\
                             <float>42</float>\
                             <string>answer</string>\
                         </content>\
-                    </AdjacentlyTaggedWorkaround>");
+                    </AdjacentlyTagged>");
             serialize_as!(empty_struct:
                 AdjacentlyTagged::Empty {}
                 => "<AdjacentlyTagged>\
@@ -1272,7 +1225,7 @@ mod without_root {
             // serde serializes flatten structs as maps, and we do not support
             // serialization of maps without root tag
             err!(flatten_struct:
-                UntaggedWorkaround::Flatten {
+                Untagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -1470,7 +1423,7 @@ mod without_root {
                             <string>answer</string>\n\
                         </Holder>");
                 serialize_as!(flatten_struct:
-                    ExternallyTaggedWorkaround::Flatten {
+                    ExternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }
@@ -1575,7 +1528,7 @@ mod without_root {
                 // serde serializes flatten structs as maps, and we do not support
                 // serialization of maps without root tag
                 err!(flatten_struct:
-                    InternallyTaggedWorkaround::Flatten {
+                    InternallyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }
@@ -1647,17 +1600,17 @@ mod without_root {
                             </content>\n\
                         </AdjacentlyTagged>");
                 serialize_as!(flatten_struct:
-                    AdjacentlyTaggedWorkaround::Flatten {
+                    AdjacentlyTagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }
-                    => "<AdjacentlyTaggedWorkaround>\n  \
+                    => "<AdjacentlyTagged>\n  \
                             <tag>Flatten</tag>\n  \
                             <content>\n    \
                                 <float>42</float>\n    \
                                 <string>answer</string>\n  \
                             </content>\n\
-                        </AdjacentlyTaggedWorkaround>");
+                        </AdjacentlyTagged>");
                 serialize_as!(empty_struct:
                     AdjacentlyTagged::Empty {}
                     => "<AdjacentlyTagged>\n  \
@@ -1710,7 +1663,7 @@ mod without_root {
                             <string>answer</string>\n\
                         </Untagged>");
                 err!(flatten_struct:
-                    UntaggedWorkaround::Flatten {
+                    Untagged::Flatten {
                         nested: Nested { float: 42.0 },
                         string: "answer",
                     }
@@ -2053,7 +2006,7 @@ mod with_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                ExternallyTaggedWorkaround::Flatten {
+                ExternallyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -2167,7 +2120,7 @@ mod with_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                InternallyTaggedWorkaround::Flatten {
+                InternallyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -2247,7 +2200,7 @@ mod with_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                AdjacentlyTaggedWorkaround::Flatten {
+                AdjacentlyTagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }
@@ -2326,7 +2279,7 @@ mod with_root {
             // NOTE: Cannot be deserialized in roundtrip due to
             // https://github.com/serde-rs/serde/issues/1183
             serialize_as_only!(flatten_struct:
-                UntaggedWorkaround::Flatten {
+                Untagged::Flatten {
                     nested: Nested { float: 42.0 },
                     string: "answer",
                 }