Skip to content
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

Add a warning that flatten and deny_unknown_fields should not be mixed. #120

Merged
merged 1 commit into from
Jan 25, 2021
Merged

Add a warning that flatten and deny_unknown_fields should not be mixed. #120

merged 1 commit into from
Jan 25, 2021

Conversation

jonasbb
Copy link
Contributor

@jonasbb jonasbb commented Jan 20, 2021

There are various bug reports about the interaction of flatten and
deny_unknown_fields. In the end they cannot really be combined, since
flatten does not consume the fields thus deny_unknown_fields will error
on them.

serde-rs/serde#1957
serde-rs/serde#1600
serde-rs/serde#1547

I'm happy to update the wording of the notice to include any suggestions.

@@ -38,6 +38,10 @@
with arbitrary string keys. The [struct flattening](attr-flatten.md) page
provides some examples.

*Note:* This attribute clashes with [`flatten`](attr-flatten.md) and might
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am reading this correctly, this line says that flatten clashes with flatten. Clashing attributes is bad, but it's not quite that bad!

@@ -5,6 +5,9 @@ The `flatten` attribute inlines keys from a field into the parent struct.
supported only within structs that have named fields, and the field to which it
is applied must be a struct or map type.

*Note:* This attribute clashes with `flatten` and might make the struct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here -- this claims flatten clashes with flatten.

…mixed.

There are various bug reports about the interaction of `flatten` and
`deny_unknown_fields`. In the end they cannot really be combined, since
flatten does not consume the fields thus `deny_unknown_fields` will error
on them.

serde-rs/serde#1957
serde-rs/serde#1600
serde-rs/serde#1547
@jonasbb
Copy link
Contributor Author

jonasbb commented Jan 24, 2021

@dtolnay Thank you for the comment. Yes I messed up the description while hastily creating this PR. I fixed the mistake.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants