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

Fix #816 - adjacently-tagged enums honor deny_unknown_fields #905

Merged
merged 2 commits into from
Apr 27, 2017

Conversation

TedDriggs
Copy link
Contributor

Implementation includes happy-path test; wasn't sure where to put the test for deny_unknown_fields, but was able to verify that locally in another crate.

#816

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.

Nicely done!

@@ -751,6 +751,31 @@ fn test_adjacently_tagged_enum() {
],
);

// unit with excess content (f, g, h)
assert_de_tokens(
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test that checks the message when an unknown field is denied. See the tests in this file that use assert_de_tokens_error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also have success case test for deny_unknown_fields

@@ -795,9 +795,19 @@ fn deserialize_adjacently_tagged_enum(

let expecting = format!("adjacently tagged enum {}", params.type_name());
let type_name = cattrs.name().deserialize_name();
let deny_unknown_fields = cattrs.deny_unknown_fields();

/// If unknown fields are allowed, we pick the visitor that can
Copy link
Member

Choose a reason for hiding this comment

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

Please replace these doc comments with ordinary // comments. This makes it look like they somehow end up in rustdoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my IDE (VSCode), /// comments on local vars are supposed to be showing up, like with JSDoc comments on private functions or members.

Copy link
Member

Choose a reason for hiding this comment

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

Oh neat. Never mind then!

} else {
quote! {
{
let mut __rk : Option<_serde::private::de::TagOrContentField> = None;
Copy link
Member

Choose a reason for hiding this comment

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

Please use absolute paths for Option and None (below as well) to avoid bugs like #737 (comment).

* Added error test when deny_unknown_fields enabled
* Fixed next_relevant_key to use absolute paths
@dtolnay dtolnay merged commit aa37caf into serde-rs:master Apr 27, 2017
@TedDriggs TedDriggs deleted the adjacent_tag_enums branch April 27, 2017 19:31
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.

None yet

2 participants