-
Notifications
You must be signed in to change notification settings - Fork 744
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
Conversation
There was a problem hiding this 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( |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
serde_derive/src/de.rs
Outdated
} else { | ||
quote! { | ||
{ | ||
let mut __rk : Option<_serde::private::de::TagOrContentField> = None; |
There was a problem hiding this comment.
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
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