-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serde >=1.0.181 has breaking changes that fails enum_::adjacently_tagged
tests
#630
Comments
The problem that serde-rs/serde#2505 change the deserialization strategy for the #[derive(Deserialize)]
#[serde(tag = "tag", content = "content")]
enum AdjacentlyTagged {
Unit,
} in serde model represented as a struct with two fields struct AdjacentlyTagged {
tag: &'static str,
content: /* depends on a tag */,
} In XML this struct could be represented as <any-name>
<tag>Unit</tag>
<!-- When tag assumes content -->
<!-- <content>...</content> -->
</any-name> Field However, after serde-rs/serde#2505 the equivalent struct looks as: struct AdjacentlyTagged {
tag: TagEnum,
content: /* depends on a tag */,
}
enum TagEnum {
Unit,
} The According to our deserialization policy, we pass to the field type the whole XML fragment, together with the tag name, so the type of field
<A>...</A>
<B>...</B>
<C>...</C> which is a typical enum E {
A,
B,
C,
} So the new representation (since serde v1.0.181) of adjacently tagged enums follows the scenario that we considered incorrect, but unfortunately, we cannot change the definition of a virtual struct, used by derive macro. Because without renaming struct Struct {
enum_field: EnumType,
}
enum EnumType {
Variant,
// ...
} to <any-name>
<enum_field>Variant</enum_field>
</any-name> or <any-name enum_field="Variant" /> Of course, this will support only unit variants. This, however, requires to check that our consistence rules keeps untouched. Especially need to check how this will work with flattened fields, because flattening is always a source of a pain in serde. |
Serialization also changed, from |
After merging serde-rs/serde#2505 the following tests are failing:
Needs investigate what's wrong and or adapt our tests, or report bug upstream
The text was updated successfully, but these errors were encountered: