Skip to content

Commit

Permalink
Because serde-rs/serde#2371 is fixed, remove workarounds for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Sep 17, 2023
1 parent c5f7ec5 commit 2226a02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ arbitrary = { version = "1.2.3", features = ["derive"], optional = true }
criterion = "0.4"
pretty_assertions = "1.3"
regex = "1"
# #[serde(other)] allowed not only inside field_identifier since 1.0.79
# https://github.com/serde-rs/serde/issues/2371 is fixed since 1.0.154
# 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.154" }
serde-value = "0.7"
tokio = { version = "1.21", default-features = false, features = ["macros", "rt"] }
tokio-test = "0.4"
Expand Down
34 changes: 11 additions & 23 deletions tests/serde-se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ 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>
/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/1904>
///
/// Anyway, deserialization of that type in roundtrip suffers from
/// <https://github.com/serde-rs/serde/issues/1183>
Expand Down Expand Up @@ -102,6 +102,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")]
Expand All @@ -111,23 +116,6 @@ enum InternallyTagged {
Empty {},
}

/// 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 {
Expand All @@ -154,7 +142,7 @@ 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>
/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/1904>
///
/// Anyway, deserialization of that type in roundtrip suffers from
/// <https://github.com/serde-rs/serde/issues/1183>
Expand Down Expand Up @@ -194,7 +182,7 @@ 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>
/// TODO: Merge into main enum after fixing <https://github.com/serde-rs/serde/issues/1904>
///
/// Anyway, deserialization of that type in roundtrip suffers from
/// <https://github.com/serde-rs/serde/issues/1183>
Expand Down Expand Up @@ -519,7 +507,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",
}
Expand Down Expand Up @@ -969,7 +957,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",
}
Expand Down Expand Up @@ -1469,7 +1457,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",
}
Expand Down

0 comments on commit 2226a02

Please sign in to comment.