From 511c235d7dac0f8ef32f0a447205328152b58c82 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Mar 2016 09:20:32 -0800 Subject: Fix last tests --- src/decoder/serde.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/decoder/serde.rs b/src/decoder/serde.rs index 099a65b..91bc8ac 100644 --- a/src/decoder/serde.rs +++ b/src/decoder/serde.rs @@ -173,6 +173,19 @@ impl de::Deserializer for Decoder { Err(first_error.unwrap_or_else(|| self.err(DecodeErrorKind::NoEnumVariants))) } + + // When #[derive(Deserialize)] encounters an unknown struct field it will + // call this method (somehow), and we want to preserve all unknown struct + // fields to return them upwards (to warn about unused keys), so we override + // that here to not tamper with our own internal state. + fn deserialize_ignored_any(&mut self, visitor: V) + -> Result + where V: de::Visitor + { + use serde::de::value::ValueDeserializer; + let mut d = <() as ValueDeserializer>::into_deserializer(()); + d.deserialize(visitor) + } } struct VariantVisitor { -- cgit v1.2.3